using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using CommonAI.Zone; using CommonAI.RTS; using CommonAI.Zone.Instance; using CommonLang; using CommonAI.Zone.Instance.ZoneEditor; namespace CommonTest { public class GameBase { // TEST public static Font global_font = new Font("song", 12, FontStyle.Italic); public static Random random = new Random(); static GameBase() { TemplateManager.getInstance().CFG.OBJECT_MOVE_TO_MIN_STEP = 1f; TemplateManager.getInstance().CFG.OBJECT_DAMAGE_FLY_SPEED = 10f; initSpells(); initSkills(); initBuffs(); } private static void initSpells() { { SpellTemplate sp = new SpellTemplate(SKILL_STRAIGHT, 100); sp.motionType = SpellTemplate.MotionType.Straight; sp.motionSpeed = 10; sp.bodySize = 10; sp.HitOnExplosion = false; sp.HitIntervalFrame = 0; sp.HitKeyFrame = new SpellTemplate.KeyFrame(0); sp.HitKeyFrame.attack = new AttackProp(); sp.HitKeyFrame.attack.attack = random.Next(10, 30); sp.HitKeyFrame.attack.freeze_time = 10; TemplateManager.getInstance().addSpell(sp); } { SpellTemplate sp = new SpellTemplate(SKILL_AOE, 30); sp.motionType = SpellTemplate.MotionType.AOE; sp.motionSpeed = 10f; sp.bodySize = 20; sp.HitOnExplosion = false; sp.HitIntervalFrame = 0; sp.HitKeyFrame = new SpellTemplate.KeyFrame(0); sp.HitKeyFrame.attack = new AttackProp(); sp.HitKeyFrame.attack.attack = random.Next(20, 50); sp.HitKeyFrame.attack.freeze_time = 0; sp.HitKeyFrame.attack.buff = new LaunchBuff(BUFF_DOT); sp.HitKeyFrame.attack.mask = AttackProp.PROP_MASK_KNOCK_FLY; TemplateManager.getInstance().addSpell(sp); } { SpellTemplate sp = new SpellTemplate(SKILL_LASER, 10); sp.motionType = SpellTemplate.MotionType.Laser; sp.motionSpeed = 10; sp.bodySize = 6000; sp.HitOnExplosion = false; sp.HitIntervalFrame = 0; sp.HitKeyFrame = new SpellTemplate.KeyFrame(0); sp.HitKeyFrame.attack = new AttackProp(); sp.HitKeyFrame.attack.attack = 200; sp.HitKeyFrame.attack.freeze_time = 0; sp.HitKeyFrame.attack.mask = AttackProp.PROP_MASK_KNOCK_FLY; TemplateManager.getInstance().addSpell(sp); } { SpellTemplate sp = new SpellTemplate(SKILL_TOWER_LASER_WALL, 1); sp.motionType = SpellTemplate.MotionType.Laser; sp.motionSpeed = 10; sp.bodySize = 6000; sp.HitOnExplosion = false; sp.HitIntervalFrame = 0; sp.HitKeyFrame = new SpellTemplate.KeyFrame(0); sp.HitKeyFrame.attack = new AttackProp(); sp.HitKeyFrame.attack.attack = 200; sp.HitKeyFrame.attack.freeze_time = 0; sp.HitKeyFrame.attack.mask = AttackProp.PROP_MASK_KNOCK_FLY; TemplateManager.getInstance().addSpell(sp); } { SpellTemplate sp = new SpellTemplate(SKILL_BINDING, 300); sp.motionType = SpellTemplate.MotionType.Binding; sp.motionSpeed = 10; sp.bodySize = 300; sp.HitOnExplosion = false; sp.HitIntervalFrame = 10; sp.HitKeyFrame = new SpellTemplate.KeyFrame(0); sp.HitKeyFrame.attack = new AttackProp(); sp.HitKeyFrame.attack.attack = random.Next(10, 20); sp.HitKeyFrame.attack.freeze_time = 0; //sp.HitKeyFrame.attack.mask = AttackProp.PROP_MASK_KNOCK_FLY; TemplateManager.getInstance().addSpell(sp); } { SpellTemplate sp = new SpellTemplate(SKILL_MISSILE, 100); sp.motionType = SpellTemplate.MotionType.Missile; sp.motionSpeed = 20; sp.bodySize = 5; sp.HitOnExplosion = true; sp.HitIntervalFrame = 0; sp.HitKeyFrame = new SpellTemplate.KeyFrame(0); sp.HitKeyFrame.attack = new AttackProp(); sp.HitKeyFrame.attack.attack = random.Next(10, 20); sp.HitKeyFrame.attack.freeze_time = 0; TemplateManager.getInstance().addSpell(sp); } { SpellTemplate sp = new SpellTemplate(SKILL_STRAIGHT_CLUSTER, 1000); sp.motionType = SpellTemplate.MotionType.Straight; sp.motionSpeed = 10; sp.bodySize = 20; sp.HitOnExplosion = true; sp.HitIntervalFrame = 0; sp.HitKeyFrame = new SpellTemplate.KeyFrame(0); sp.HitKeyFrame.spell = new LaunchSpell(SKILL_STRAIGHT); sp.HitKeyFrame.spell.count = 32; sp.HitKeyFrame.spell.pos_type = LaunchSpell.PosType.POS_TYPE_CYCLE; sp.HitKeyFrame.attack = new AttackProp(); sp.HitKeyFrame.attack.attack = 200; sp.HitKeyFrame.attack.freeze_time = 10; TemplateManager.getInstance().addSpell(sp); } { SpellTemplate sp = new SpellTemplate(SKILL_TOWER_SUB_JIANYU, 30); sp.motionType = SpellTemplate.MotionType.Immovability; sp.motionSpeed = 10; sp.bodySize = 10; sp.HitOnExplosion = false; sp.HitIntervalFrame = 0; sp.HitKeyFrame = new SpellTemplate.KeyFrame(0); sp.HitKeyFrame.attack = new AttackProp(); sp.HitKeyFrame.attack.attack = random.Next(10, 30); sp.HitKeyFrame.attack.freeze_time = 0; TemplateManager.getInstance().addSpell(sp); } { SpellTemplate sp = new SpellTemplate(SKILL_TOWER_HELL_JIANYU, 200); sp.motionType = SpellTemplate.MotionType.Immovability; sp.motionSpeed = 10; sp.bodySize = 200; sp.HitOnExplosion = false; sp.HitIntervalFrame = 10; sp.HitKeyFrame = new SpellTemplate.KeyFrame(0); sp.HitKeyFrame.spell = new LaunchSpell(SKILL_TOWER_SUB_JIANYU); sp.HitKeyFrame.spell.pos_type = LaunchSpell.PosType.POS_TYPE_RANDOM_FOR_SPELL; sp.HitKeyFrame.spell.count = 5; TemplateManager.getInstance().addSpell(sp); } { SpellTemplate sp = new SpellTemplate(SKILL_ORBIT_CYCLE, 300); sp.motionType = SpellTemplate.MotionType.Binding; sp.motionSpeed = 0; sp.rotateSpeed = 0.1f; sp.bodySize = 10; sp.OrbitDistance = BodySize * 5; sp.IsBindingOrbit = true; sp.HitOnExplosion = false; sp.HitIntervalFrame = 10; sp.HitKeyFrame = new SpellTemplate.KeyFrame(0); sp.HitKeyFrame.attack = new AttackProp(); sp.HitKeyFrame.attack.attack = random.Next(10, 30); sp.HitKeyFrame.attack.freeze_time = 0; //sp.HitKeyFrame.spell = new LaunchSpell(SKILL_STRAIGHT); SpellTemplate.KeyFrame kf = new SpellTemplate.KeyFrame(10); kf.summon = new SummonUnit(test_InitUnitInfo_RandomSkill(0, "Summon", 300)); sp.AddKeyFrame(kf); TemplateManager.getInstance().addSpell(sp); } { SpellTemplate sp = new SpellTemplate(SKILL_TOWER_SUMMON, 10); sp.motionType = SpellTemplate.MotionType.Immovability; sp.motionSpeed = 10; sp.bodySize = 200; sp.HitOnExplosion = false; sp.HitIntervalFrame = 0; SpellTemplate.KeyFrame kf = new SpellTemplate.KeyFrame(0); kf.spell = new LaunchSpell(SKILL_TOWER_SUB_SUMMON); kf.spell.pos_type = LaunchSpell.PosType.POS_TYPE_RANDOM_FOR_SPELL; kf.spell.count = 3; sp.AddKeyFrame(kf); TemplateManager.getInstance().addSpell(sp); } { SpellTemplate sp = new SpellTemplate(SKILL_TOWER_SUB_SUMMON, 1); sp.motionType = SpellTemplate.MotionType.Immovability; sp.motionSpeed = 10; sp.bodySize = 10; sp.HitOnExplosion = false; sp.HitIntervalFrame = 0; SpellTemplate.KeyFrame kf = new SpellTemplate.KeyFrame(0); kf.summon = new SummonUnit(test_InitUnitInfo_RandomSkill(0, "Summon", 300)); sp.AddKeyFrame(kf); TemplateManager.getInstance().addSpell(sp); } } private static void initSkills() { // init skill { { UnitActionData act = new UnitActionData(6); UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(3); kf.attack = new AttackProp(); //kf.attack.mask = AttackProp.PROP_MASK_KNOCK_FLY; kf.attack.attack = random.Next(20, 30); act.AddKeyFrame(kf); SkillTemplate skill = new SkillTemplate(SKILL_NORMAL_ATTACK); skill.name = "SKILL_NORMAL_ATTACK"; skill.cool_down = 30; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeMelee; skill.action_queue.Add(act); TemplateManager.getInstance().addSkill(skill); } { UnitActionData act = new UnitActionData(6); UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.spell = new LaunchSpell(SKILL_STRAIGHT); act.AddKeyFrame(kf); SkillTemplate skill = new SkillTemplate(SKILL_STRAIGHT); skill.name = "SKILL_STRAIGHT"; skill.cool_down = 130; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeRanged; skill.action_queue.Add(act); TemplateManager.getInstance().addSkill(skill); } { UnitActionData act = new UnitActionData(6); UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.spell = new LaunchSpell(SKILL_AOE); act.AddKeyFrame(kf); SkillTemplate skill = new SkillTemplate(SKILL_AOE); skill.name = "SKILL_AOE"; skill.cool_down = 130; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeMelee; skill.action_queue.Add(act); TemplateManager.getInstance().addSkill(skill); } { UnitActionData act = new UnitActionData(6); UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.spell = new LaunchSpell(SKILL_LASER); act.AddKeyFrame(kf); SkillTemplate skill = new SkillTemplate(SKILL_LASER); skill.name = "SKILL_LASER"; skill.cool_down = 60; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeRanged; skill.action_queue.Add(act); TemplateManager.getInstance().addSkill(skill); } { UnitActionData act = new UnitActionData(6); UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.spell = new LaunchSpell(SKILL_TOWER_LASER_WALL); kf.spell.pos_type = LaunchSpell.PosType.POS_TYPE_FAN; kf.spell.angle = RTSMath.PI_DIV_2; kf.spell.count = 9; act.AddKeyFrame(kf); SkillTemplate skill = new SkillTemplate(SKILL_TOWER_LASER_WALL); skill.name = "SKILL_LASER_WALL"; skill.cool_down = 1; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeRanged; skill.action_queue.Add(act); TemplateManager.getInstance().addSkill(skill); } { UnitActionData act = new UnitActionData(300); act.is_none_block = true; UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.spell = new LaunchSpell(SKILL_BINDING); act.AddKeyFrame(kf); SkillTemplate skill = new SkillTemplate(SKILL_BINDING); skill.name = "SKILL_BINDING"; skill.cool_down = 360; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeMelee; skill.action_queue.Add(act); skill.is_moveable = true; TemplateManager.getInstance().addSkill(skill); } { UnitActionData act = new UnitActionData(6); UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.spell = new LaunchSpell(SKILL_MISSILE); act.AddKeyFrame(kf); SkillTemplate skill = new SkillTemplate(SKILL_MISSILE); skill.name = "SKILL_MISSILE"; skill.cool_down = 10; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeRanged; skill.action_queue.Add(act); TemplateManager.getInstance().addSkill(skill); } { UnitActionData act = new UnitActionData(6); UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.spell = new LaunchSpell(SKILL_STRAIGHT_CLUSTER); kf.spell.pos_type = LaunchSpell.PosType.POS_TYPE_FAN; //kf.spell.angle = RTSMath.PI_DIV_2; // kf.spell.count = 8; act.AddKeyFrame(kf); SkillTemplate skill = new SkillTemplate(SKILL_STRAIGHT_CLUSTER); skill.name = "SKILL_STRAIGHT_CLUSTER"; skill.cool_down = 90; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = GuardRangeBuilding; skill.action_queue.Add(act); TemplateManager.getInstance().addSkill(skill); } // SKILL_MELEE_ATTACK_4 { SkillTemplate skill = new SkillTemplate(SKILL_MELEE_ATTACK_4); skill.name = "SKILL_MELEE_ATTACK_4"; skill.cool_down = 10; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeMelee; for (int i = 0; i < 4; i++) { UnitActionData act = new UnitActionData(10); UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.attack = new AttackProp(); kf.attack.mask = AttackProp.PROP_MASK_DAMAGE; kf.attack.attack = random.Next(20, 30); kf.attack.hit_move = new StartMove(-MoveSpeed, 0, 5); kf.start_move = new StartMove(MoveSpeed, 0, 5); act.AddKeyFrame(kf); skill.action_queue.Add(act); } TemplateManager.getInstance().addSkill(skill); } // SKILL_HELL_JIANYU { SkillTemplate skill = new SkillTemplate(SKILL_TOWER_HELL_JIANYU); skill.name = "SKILL_TOWER_HELL_JIANYU"; skill.cool_down = 120; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeRanged; skill.is_launch_body = false; UnitActionData act = new UnitActionData(10); UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.spell = new LaunchSpell(SKILL_TOWER_HELL_JIANYU); act.AddKeyFrame(kf); skill.action_queue.Add(act); TemplateManager.getInstance().addSkill(skill); } // SKILL_HELL_FIRE { SkillTemplate skill = new SkillTemplate(SKILL_TOWER_HELL_FIRE); skill.name = "SKILL_TOWER_HELL_FIRE"; skill.cool_down = 120; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeRanged; skill.is_launch_body = false; UnitActionData act = new UnitActionData(10); UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.attack = new AttackProp(); kf.attack.attack = 100; act.AddKeyFrame(kf); skill.action_queue.Add(act); TemplateManager.getInstance().addSkill(skill); } // SKILL_SUMMON { SkillTemplate skill = new SkillTemplate(SKILL_TOWER_SUMMON); skill.name = "SKILL_TOWER_SUMMON"; skill.cool_down = 120; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeRanged; skill.is_launch_body = false; UnitActionData act = new UnitActionData(10); UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.spell = new LaunchSpell(SKILL_TOWER_SUMMON); act.AddKeyFrame(kf); skill.action_queue.Add(act); TemplateManager.getInstance().addSkill(skill); } // SKILL_ACTOR_SLIP { SkillTemplate skill = new SkillTemplate(SKILL_ACTOR_SLIP); skill.name = "SKILL_ACTOR_SLIP"; skill.cool_down = 10; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeRanged; skill.is_launch_body = false; UnitActionData act = new UnitActionData(10); act.is_none_block = true; act.is_face_to_target = true; UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.start_move = new StartMove(MoveSpeed * 3, 0, 10); act.AddKeyFrame(kf); skill.action_queue.Add(act); TemplateManager.getInstance().addSkill(skill); } // SKILL_ACTOR_SLIP { SkillTemplate skill = new SkillTemplate(SKILL_ORBIT_CYCLE); skill.name = "SKILL_ORBIT_CYCLE"; skill.cool_down = 300; skill.attackAngle = (float)(Math.PI / 2); skill.attackRange = AttackRangeMelee; skill.is_launch_body = true; UnitActionData act = new UnitActionData(10); UnitActionData.KeyFrame kf = new UnitActionData.KeyFrame(0); kf.spell = new LaunchSpell(SKILL_ORBIT_CYCLE); kf.spell.count = 10; kf.spell.pos_type = LaunchSpell.PosType.POS_TYPE_CYCLE; act.AddKeyFrame(kf); skill.action_queue.Add(act); TemplateManager.getInstance().addSkill(skill); } } } private static void initBuffs() { // BUFF DOT { BuffTemplate buff = new BuffTemplate(BUFF_DOT, 300); buff.HitIntervalFrame = 10; buff.HitKeyFrame = new BuffTemplate.KeyFrame(0); buff.HitKeyFrame.attack = new AttackProp(); buff.HitKeyFrame.attack.attack = 10; buff.HitKeyFrame.attack.freeze_time = 0; TemplateManager.getInstance().addBuff(buff); } } //------------------------------------------------------------------------ public const int SKILL_NORMAL_ATTACK = 1; public const int SKILL_STRAIGHT = 2; public const int SKILL_AOE = 3; public const int SKILL_LASER = 4; public const int SKILL_BINDING = 5; public const int SKILL_MISSILE = 6; public const int SKILL_STRAIGHT_CLUSTER = 7; public const int SKILL_MELEE_ATTACK_4 = 8; public const int SKILL_ORBIT_CYCLE = 9; public const int SKILL_TOWER_HELL_JIANYU = 10; public const int SKILL_TOWER_SUB_JIANYU = 11; public const int SKILL_TOWER_SUMMON = 12; public const int SKILL_TOWER_SUB_SUMMON = 13; public const int SKILL_TOWER_LASER_WALL = 100; public const int SKILL_TOWER_HELL_FIRE = 101; public const int SKILL_ACTOR_SLIP = 1000; private static int[] RandomSkills = new int[] { SKILL_NORMAL_ATTACK, SKILL_STRAIGHT, SKILL_AOE, SKILL_BINDING, SKILL_MISSILE, SKILL_MELEE_ATTACK_4, }; //------------------------------------------------------------------------ public const int BUFF_DOT = 1; //------------------------------------------------------------------------ public const int SpaceDIV = 800; public const float BodySize = 25; public const float GuardRange = 800; public const float GuardRangeBuilding = 800; public const float MoveSpeed = 15f; public const float AttackRangeMelee = 100; public const float AttackRangeRanged = 400; //------------------------------------------------------------------------ public static UnitInfo test_InitUnitInfo( int force, string name, bool melee, bool elite) { UnitInfo info = new UnitInfo(); info.type = UnitInfo.UnitType.TYPE_NPC; info.name = name; info.force = (byte)force; info.bodyHeight = 10; info.bodySize = BodySize; info.moveSpeed = MoveSpeed; info.guardRange = GuardRange; info.HealthPoint = 100; if (melee) { info.baseSkillID = SKILL_NORMAL_ATTACK; //info.skills.Add(SKILL_AOE); info.moveSpeed += 1; } else { info.baseSkillID = SKILL_MISSILE; //info.skills.Add(SKILL_STRAIGHT); } if (elite) { info.bodySize = BodySize * 2f; info.HealthPoint = 1000; info.baseSkillID = SKILL_NORMAL_ATTACK; //info.skills.Add(SKILL_NORMAL_ATTACK); //info.skills.Add(SKILL_STRAIGHT); info.skills.Add(SKILL_AOE); //info.skills.Add(SKILL_BINDING); //info.skills.Add(SKILL_LASER); //info.skills.Add(SKILL_BINDING); info.skills.Add(SKILL_MISSILE); } return info; } public static UnitInfo test_InitUnitInfo_RandomSkill(int force, string name, int lifeTime) { UnitInfo un = test_InitUnitInfo(force, name, true, false); un.type = UnitInfo.UnitType.TYPE_SUMMON; un.LifeTime = lifeTime; un.skills.Clear(); un.baseSkillID = CUtils.getRandom(RandomSkills); return un; } public static UnitInfo test_InitBuildingInfo(int force, string name) { UnitInfo info = new UnitInfo(); info.type = UnitInfo.UnitType.TYPE_BUILDING; info.name = name; info.force = (byte)force; info.bodyHeight = 100; info.bodySize = BodySize * 4f; info.moveSpeed = 0; info.guardRange = GuardRangeBuilding; info.HealthPoint = 10000; info.baseSkillID = SKILL_TOWER_LASER_WALL; info.skills.Add(SKILL_STRAIGHT_CLUSTER); return info; } public static UnitInfo test_InitTownerInfo(int force, string name) { UnitInfo info = new UnitInfo(); info.type = UnitInfo.UnitType.TYPE_BUILDING; info.name = name; info.force = (byte)force; info.bodyHeight = 50; info.bodySize = BodySize * 2f; info.moveSpeed = 0; info.guardRange = GuardRangeBuilding; info.HealthPoint = 1000; info.baseSkillID = SKILL_LASER; info.skills.Add(SKILL_TOWER_SUMMON); info.skills.Add(SKILL_TOWER_HELL_FIRE); info.skills.Add(SKILL_TOWER_HELL_JIANYU); return info; } //------------------------------------------------------------------------------------------ public class InitZoneInfo { readonly public ZoneInfo Info; public List mapdata_add_buildings = new List(); public List mapdata_add_barracks = new List(); public InitZoneInfo(ZoneInfo info) { this.Info = info; } public void initGame(InstanceZone zone) { foreach (AddUnitAction act in mapdata_add_buildings) { zone.pushAction(act); } foreach (ZoneRegion act in mapdata_add_barracks) { zone.addFlag(act); } } } public static InitZoneInfo test_InitZoneInfo(Bitmap mapdata) { if (mapdata != null) { int xc = mapdata.Width; int yc = mapdata.Height; int mGridXCount = xc; int mGridYCount = yc; int mCellW = 200; int mCellH = 200; ZoneInfo zinf = new ZoneInfo(xc, yc, mCellW, mCellH); // init astar map { for (int x = 0; x < xc; ++x) { for (int y = 0; y < yc; ++y) { Color c = mapdata.GetPixel(x, y); int rgb = (int)(c.ToArgb() & 0xFFFFFF); zinf.TerrainMatrix[x, y] = rgb; } } } return new InitZoneInfo(zinf); } else { int xc = 50; int yc = 50; ZoneInfo zinf = new ZoneInfo(xc, yc, 128, 128); for (int x = 0; x < xc; ++x) { for (int y = 0; y < yc; ++y) { if ((random.Next() % 10000) > 9500) { zinf.TerrainMatrix[x, y] = 1; } } } return new InitZoneInfo(zinf); } } public static void test_init3C(InitZoneInfo ini) { ZoneInfo mZoneInfo = ini.Info; List mapdata_add_buildings = ini.mapdata_add_buildings; List mapdata_add_barracks = ini.mapdata_add_barracks; int mGridXCount = RTSMath.roundMod(mZoneInfo.TotalWidth, mZoneInfo.GridCellW); int mGridYCount = RTSMath.roundMod(mZoneInfo.TotalHeight, mZoneInfo.GridCellH); int mWidth = mZoneInfo.TotalWidth; int mHeight = mZoneInfo.TotalHeight; int mCellW = mZoneInfo.GridCellW; int mCellH = mZoneInfo.GridCellH; int rc = 3; for (int i = 0; i < rc; i++) { float size = 256; float sx1 = size * 2; float sx2 = mZoneInfo.TotalWidth - size * 2; float sy = (mZoneInfo.TotalHeight / rc) * i + (mZoneInfo.TotalHeight / rc) / 2; UnitInfo info1m = test_InitUnitInfo(SceneLOL.UNIT_FORCE_A, "Spawned A", true, false); UnitInfo info2m = test_InitUnitInfo(SceneLOL.UNIT_FORCE_B, "Spawned B", true, false); UnitInfo info1r = test_InitUnitInfo(SceneLOL.UNIT_FORCE_A, "Spawned A", false, false); UnitInfo info2r = test_InitUnitInfo(SceneLOL.UNIT_FORCE_B, "Spawned B", false, false); UnitInfo info1e = test_InitUnitInfo(SceneLOL.UNIT_FORCE_A, "Spawned A", true, true); UnitInfo info2e = test_InitUnitInfo(SceneLOL.UNIT_FORCE_B, "Spawned B", true, true); ZoneRegion rg1m = new ZoneRegion("3C_Spawned_A_Melee_" + i, sx1, sy, size); ZoneRegion rg2m = new ZoneRegion("3C_Spawned_B_Melee_" + i, sx2, sy, size); ZoneRegion rg1r = new ZoneRegion("3C_Spawned_A_Range_" + i, sx1, sy, size); ZoneRegion rg2r = new ZoneRegion("3C_Spawned_B_Range_" + i, sx2, sy, size); ZoneRegion rg1e = new ZoneRegion("3C_Spawned_A_Elite_" + i, sx1, sy, size); ZoneRegion rg2e = new ZoneRegion("3C_Spawned_B_Elite_" + i, sx2, sy, size); SpawnUnitTrigger sam = new SpawnUnitTrigger(info1m, 100, 1, new Vector2(sx2, sy)); SpawnUnitTrigger sbm = new SpawnUnitTrigger(info2m, 100, 1, new Vector2(sx1, sy)); SpawnUnitTrigger sar = new SpawnUnitTrigger(info1r, 100, 1, new Vector2(sx2, sy)); SpawnUnitTrigger sbr = new SpawnUnitTrigger(info2r, 100, 1, new Vector2(sx1, sy)); SpawnUnitTrigger sae = new SpawnUnitTrigger(info1e, 1000, 1, new Vector2(sx2, sy)); SpawnUnitTrigger sbe = new SpawnUnitTrigger(info2e, 1000, 1, new Vector2(sx1, sy)); rg1m.OnZoneUpdate += sam.onUpdate; rg2m.OnZoneUpdate += sbm.onUpdate; rg1r.OnZoneUpdate += sar.onUpdate; rg2r.OnZoneUpdate += sbr.onUpdate; rg1e.OnZoneUpdate += sae.onUpdate; rg2e.OnZoneUpdate += sbe.onUpdate; mapdata_add_barracks.Add(rg1m); mapdata_add_barracks.Add(rg2m); mapdata_add_barracks.Add(rg1r); mapdata_add_barracks.Add(rg2r); mapdata_add_barracks.Add(rg1e); mapdata_add_barracks.Add(rg2e); UnitInfo b1 = test_InitBuildingInfo(SceneLOL.UNIT_FORCE_A, "Building A"); UnitInfo b2 = test_InitBuildingInfo(SceneLOL.UNIT_FORCE_B, "Building B"); mapdata_add_buildings.Add(new AddUnitAction(b1, sx1 - size, sy, 0)); mapdata_add_buildings.Add(new AddUnitAction(b2, sx2 + size, sy, 0)); } } public static void test_init4A(InitZoneInfo ini) { ZoneInfo mZoneInfo = ini.Info; List mapdata_add_buildings = ini.mapdata_add_buildings; List mapdata_add_barracks = ini.mapdata_add_barracks; int mGridXCount = RTSMath.roundMod(mZoneInfo.TotalWidth, mZoneInfo.GridCellW); int mGridYCount = RTSMath.roundMod(mZoneInfo.TotalHeight, mZoneInfo.GridCellH); int mWidth = mZoneInfo.TotalWidth; int mHeight = mZoneInfo.TotalHeight; int mCellW = mZoneInfo.GridCellW; int mCellH = mZoneInfo.GridCellH; // 四家互A float size = 256; Vector2 vc = new Vector2(mWidth / 2, mHeight / 2); Vector2 v1 = new Vector2(size * 2, size * 2); Vector2 v2 = new Vector2(mWidth - size * 2, size * 2); Vector2 v3 = new Vector2(mWidth - size * 2, mHeight - size * 2); Vector2 v4 = new Vector2(size * 2, mHeight - size * 2); UnitInfo info1r = test_InitUnitInfo(SceneLOL.UNIT_FORCE_A, "Spawned A", false, false); UnitInfo info2r = test_InitUnitInfo(SceneLOL.UNIT_FORCE_A, "Spawned B", false, false); UnitInfo info3r = test_InitUnitInfo(SceneLOL.UNIT_FORCE_B, "Spawned C", false, false); UnitInfo info4r = test_InitUnitInfo(SceneLOL.UNIT_FORCE_B, "Spawned D", false, false); UnitInfo info1m = test_InitUnitInfo(SceneLOL.UNIT_FORCE_A, "Spawned A", true, false); UnitInfo info2m = test_InitUnitInfo(SceneLOL.UNIT_FORCE_A, "Spawned B", true, false); UnitInfo info3m = test_InitUnitInfo(SceneLOL.UNIT_FORCE_B, "Spawned C", true, false); UnitInfo info4m = test_InitUnitInfo(SceneLOL.UNIT_FORCE_B, "Spawned D", true, false); UnitInfo info1e = test_InitUnitInfo(SceneLOL.UNIT_FORCE_A, "Spawned A", true, true); UnitInfo info2e = test_InitUnitInfo(SceneLOL.UNIT_FORCE_A, "Spawned B", true, true); UnitInfo info3e = test_InitUnitInfo(SceneLOL.UNIT_FORCE_B, "Spawned C", true, true); UnitInfo info4e = test_InitUnitInfo(SceneLOL.UNIT_FORCE_B, "Spawned D", true, true); ZoneRegion rg_info1r = new ZoneRegion("4A_rg_info1r_", v1.x, v1.y, size); ZoneRegion rg_info2r = new ZoneRegion("4A_rg_info2r_", v2.x, v2.y, size); ZoneRegion rg_info3r = new ZoneRegion("4A_rg_info3r_", v3.x, v3.y, size); ZoneRegion rg_info4r = new ZoneRegion("4A_rg_info4r_", v4.x, v4.y, size); ZoneRegion rg_info1m = new ZoneRegion("4A_rg_info1m_", v1.x, v1.y, size); ZoneRegion rg_info2m = new ZoneRegion("4A_rg_info2m_", v2.x, v2.y, size); ZoneRegion rg_info3m = new ZoneRegion("4A_rg_info3m_", v3.x, v3.y, size); ZoneRegion rg_info4m = new ZoneRegion("4A_rg_info4m_", v4.x, v4.y, size); ZoneRegion rg_info1e = new ZoneRegion("4A_rg_info1e_", v1.x, v1.y, size); ZoneRegion rg_info2e = new ZoneRegion("4A_rg_info2e_", v2.x, v2.y, size); ZoneRegion rg_info3e = new ZoneRegion("4A_rg_info3e_", v3.x, v3.y, size); ZoneRegion rg_info4e = new ZoneRegion("4A_rg_info4e_", v4.x, v4.y, size); SpawnUnitTrigger s1r = new SpawnUnitTrigger(info1r, 20, 1, vc); SpawnUnitTrigger s2r = new SpawnUnitTrigger(info2r, 20, 1, vc); SpawnUnitTrigger s3r = new SpawnUnitTrigger(info3r, 20, 1, vc); SpawnUnitTrigger s4r = new SpawnUnitTrigger(info4r, 20, 1, vc); SpawnUnitTrigger s1m = new SpawnUnitTrigger(info1m, 20, 1, vc); SpawnUnitTrigger s2m = new SpawnUnitTrigger(info2m, 20, 1, vc); SpawnUnitTrigger s3m = new SpawnUnitTrigger(info3m, 20, 1, vc); SpawnUnitTrigger s4m = new SpawnUnitTrigger(info4m, 20, 1, vc); SpawnUnitTrigger s1e = new SpawnUnitTrigger(info1e, 1000, 1, vc); SpawnUnitTrigger s2e = new SpawnUnitTrigger(info2e, 1000, 1, vc); SpawnUnitTrigger s3e = new SpawnUnitTrigger(info3e, 1000, 1, vc); SpawnUnitTrigger s4e = new SpawnUnitTrigger(info4e, 1000, 1, vc); rg_info1r.OnZoneUpdate += s1r.onUpdate; rg_info2r.OnZoneUpdate += s2r.onUpdate; rg_info3r.OnZoneUpdate += s3r.onUpdate; rg_info4r.OnZoneUpdate += s4r.onUpdate; rg_info1m.OnZoneUpdate += s1m.onUpdate; rg_info2m.OnZoneUpdate += s2m.onUpdate; rg_info3m.OnZoneUpdate += s3m.onUpdate; rg_info4m.OnZoneUpdate += s4m.onUpdate; rg_info1e.OnZoneUpdate += s1e.onUpdate; rg_info2e.OnZoneUpdate += s2e.onUpdate; rg_info3e.OnZoneUpdate += s3e.onUpdate; rg_info4e.OnZoneUpdate += s4e.onUpdate; mapdata_add_barracks.Add(rg_info1r); mapdata_add_barracks.Add(rg_info2r); mapdata_add_barracks.Add(rg_info3r); mapdata_add_barracks.Add(rg_info4r); mapdata_add_barracks.Add(rg_info1m); mapdata_add_barracks.Add(rg_info2m); mapdata_add_barracks.Add(rg_info3m); mapdata_add_barracks.Add(rg_info4m); mapdata_add_barracks.Add(rg_info1e); mapdata_add_barracks.Add(rg_info2e); mapdata_add_barracks.Add(rg_info3e); mapdata_add_barracks.Add(rg_info4e); MathVector.move(v1, -size, -size); MathVector.move(v2, size, -size); MathVector.move(v3, -size, -size); MathVector.move(v4, -size, size); UnitInfo b1 = test_InitBuildingInfo(SceneLOL.UNIT_FORCE_A, "Building A"); UnitInfo b2 = test_InitBuildingInfo(SceneLOL.UNIT_FORCE_A, "Building B"); UnitInfo b3 = test_InitBuildingInfo(SceneLOL.UNIT_FORCE_B, "Building C"); UnitInfo b4 = test_InitBuildingInfo(SceneLOL.UNIT_FORCE_B, "Building D"); mapdata_add_buildings.Add(new AddUnitAction(b1, v1.x, v1.y, 0)); mapdata_add_buildings.Add(new AddUnitAction(b2, v2.x, v2.y, 0)); mapdata_add_buildings.Add(new AddUnitAction(b3, v3.x, v3.y, 0)); mapdata_add_buildings.Add(new AddUnitAction(b4, v4.x, v4.y, 0)); } public static void test_initLOL(InitZoneInfo ini) { ZoneInfo mZoneInfo = ini.Info; List mapdata_add_buildings = ini.mapdata_add_buildings; List mapdata_add_barracks = ini.mapdata_add_barracks; ZoneInfo zinf = mZoneInfo; int mGridXCount = RTSMath.roundMod(mZoneInfo.TotalWidth, mZoneInfo.GridCellW); int mGridYCount = RTSMath.roundMod(mZoneInfo.TotalHeight, mZoneInfo.GridCellH); int mWidth = mZoneInfo.TotalWidth; int mHeight = mZoneInfo.TotalHeight; int mCellW = mZoneInfo.GridCellW; int mCellH = mZoneInfo.GridCellH; const int MAP_MASK_COLOR_BASE_FORCE_A = 0x00FF0000; const int MAP_MASK_COLOR_BASE_FORCE_B = 0x000000FF; const int MAP_MASK_COLOR_TOWER_FORCE_A = 0x00FFFF00; const int MAP_MASK_COLOR_TOWER_FORCE_B = 0x00FF00FF; const int MAP_MASK_COLOR_BARRACK_FORCE_A = 0x00FFFFFF; const int MAP_MASK_COLOR_BARRACK_FORCE_B = 0x00808080; const int MAP_MASK_COLOR_WP_L = 0x00800000; const int MAP_MASK_COLOR_WP_D = 0x00FF8080; Vector2[] force_a_L = new Vector2[] { new Vector2(), new Vector2(), }; Vector2[] force_a_C = new Vector2[] { new Vector2(), }; Vector2[] force_a_D = new Vector2[] { new Vector2(), new Vector2(), }; Vector2[] force_b_L = new Vector2[] { new Vector2(), new Vector2(), }; Vector2[] force_b_C = new Vector2[] { new Vector2(), }; Vector2[] force_b_D = new Vector2[] { new Vector2(), new Vector2(), }; Vector2[][] force_a_P = new Vector2[3][] { force_a_L, force_a_C, force_a_D }; Vector2[][] force_b_P = new Vector2[3][] { force_b_L, force_b_C, force_b_D }; for (int x = 0; x < mGridXCount; ++x) { for (int y = 0; y < mGridYCount; ++y) { float cx = x * mCellW + mCellW / 2; float cy = y * mCellH + mCellH / 2; int rgb = zinf.TerrainMatrix[x, y]; if (rgb == MAP_MASK_COLOR_BASE_FORCE_A) { zinf.TerrainMatrix[x, y] = 0; UnitInfo b = test_InitBuildingInfo(SceneLOL.UNIT_FORCE_A, "Building A"); mapdata_add_buildings.Add(new AddUnitAction(b, cx, cy, 0)); force_b_L[1].x = cx; force_b_L[1].y = cy; force_b_C[0].x = cx; force_b_C[0].y = cy; force_b_D[1].x = cx; force_b_D[1].y = cy; } if (rgb == MAP_MASK_COLOR_BASE_FORCE_B) { zinf.TerrainMatrix[x, y] = 0; UnitInfo b = test_InitBuildingInfo(SceneLOL.UNIT_FORCE_B, "Building B"); mapdata_add_buildings.Add(new AddUnitAction(b, cx, cy, 0)); force_a_L[1].x = cx; force_a_L[1].y = cy; force_a_C[0].x = cx; force_a_C[0].y = cy; force_a_D[1].x = cx; force_a_D[1].y = cy; } if (rgb == MAP_MASK_COLOR_TOWER_FORCE_A) { UnitInfo b = test_InitTownerInfo(SceneLOL.UNIT_FORCE_A, "Tower A"); mapdata_add_buildings.Add(new AddUnitAction(b, cx, cy, 0)); } if (rgb == MAP_MASK_COLOR_TOWER_FORCE_B) { UnitInfo b = test_InitTownerInfo(SceneLOL.UNIT_FORCE_B, "Tower B"); mapdata_add_buildings.Add(new AddUnitAction(b, cx, cy, 0)); } } } for (int x = 0; x < mGridXCount; ++x) { for (int y = 0; y < mGridYCount; ++y) { float cx = x * mCellW + mCellW / 2; float cy = y * mCellH + mCellH / 2; int rgb = zinf.TerrainMatrix[x, y]; if (rgb == MAP_MASK_COLOR_WP_L) { zinf.TerrainMatrix[x, y] = 0; force_a_L[0].x = cx; force_a_L[0].y = cy; force_b_L[0].x = cx; force_b_L[0].y = cy; } if (rgb == MAP_MASK_COLOR_WP_D) { zinf.TerrainMatrix[x, y] = 0; force_a_D[0].x = cx; force_a_D[0].y = cy; force_b_D[0].x = cx; force_b_D[0].y = cy; } } } float size = 256; int fa = 0; int fb = 0; for (int y = 0; y < mGridYCount; ++y) { for (int x = 0; x < mGridXCount; ++x) { float cx = x * mCellW + mCellW / 2; float cy = y * mCellH + mCellH / 2; int rgb = zinf.TerrainMatrix[x, y]; if (rgb == MAP_MASK_COLOR_BARRACK_FORCE_A) { zinf.TerrainMatrix[x, y] = 0; ZoneRegion rgm = new ZoneRegion("rgA_" + cx + "_" + cy, cx, cy, size); UnitInfo ifm = test_InitUnitInfo(SceneLOL.UNIT_FORCE_A, "Spawned A", false, false); UnitInfo ifr = test_InitUnitInfo(SceneLOL.UNIT_FORCE_A, "Spawned A", true, false); UnitInfo ife = test_InitUnitInfo(SceneLOL.UNIT_FORCE_A, "Spawned A", true, true); SpawnUnitTrigger tgm = new SpawnUnitTrigger(ifm, 200, 1, force_a_P[fa]); SpawnUnitTrigger tgr = new SpawnUnitTrigger(ifr, 200, 1, force_a_P[fa]); SpawnUnitTrigger tge = new SpawnUnitTrigger(ife, 200, 1, force_a_P[fa]); rgm.OnZoneUpdate += tgm.onUpdate; rgm.OnZoneUpdate += tgr.onUpdate; rgm.OnZoneUpdate += tge.onUpdate; mapdata_add_barracks.Add(rgm); fa++; } if (rgb == MAP_MASK_COLOR_BARRACK_FORCE_B) { zinf.TerrainMatrix[x, y] = 0; ZoneRegion rgm = new ZoneRegion("rgB_" + cx + "_" + cy, cx, cy, size); UnitInfo ifm = test_InitUnitInfo(SceneLOL.UNIT_FORCE_B, "Spawned B", false, false); UnitInfo ifr = test_InitUnitInfo(SceneLOL.UNIT_FORCE_B, "Spawned B", true, false); UnitInfo ife = test_InitUnitInfo(SceneLOL.UNIT_FORCE_B, "Spawned B", true, true); SpawnUnitTrigger tgm = new SpawnUnitTrigger(ifm, 200, 1, force_b_P[fb]); SpawnUnitTrigger tgr = new SpawnUnitTrigger(ifr, 200, 1, force_b_P[fb]); SpawnUnitTrigger tge = new SpawnUnitTrigger(ife, 200, 1, force_b_P[fb]); rgm.OnZoneUpdate += tgm.onUpdate; rgm.OnZoneUpdate += tgr.onUpdate; rgm.OnZoneUpdate += tge.onUpdate; mapdata_add_barracks.Add(rgm); fb++; } } } } } }