Пример #1
0
    //Adds unit to the formation. Used only for setting up and merging formations
    void AddUnit(Infantry AI)
    {
        //Add to an empty position in the backline if possible, else create new line for them

        RemoveEmptyBackLines();

        if (LineHasOpen(line.Count - 1))
        {
            for (int i = 0; i < line [line.Count - 1].spot.Count; i++)
            {
                Vector2Int checkSpot = new Vector2Int(i, line.Count - 1);
                if (!HasUnit(checkSpot) && !IsBlocked(checkSpot))
                {
                    AI.EnterFormation(this, checkSpot, formationID);
                    AssignPosition(AI, checkSpot);
                    return;
                }
            }
            Debug.LogError("LineHasOpen has said there is a spot available, but no spots were available");
        }
        else
        {
            //If the backline is full, make a new one and plop him in there.

            AddBackLine(width);
            Vector2Int newSpot = new Vector2Int(0, line.Count - 1);
            AI.EnterFormation(this, newSpot, formationID);
            AssignPosition(AI, newSpot);
        }

        var newSpots = GetStandardSpots(transform.position, transform.forward, transform.right, width);

        ChangeShape(line, newSpots);
    }
Пример #2
0
    void FindEmptySpot(Infantry AI)
    {
        for (int y = 0; y < line.Count; y++)
        {
            for (int x = 0; x < line [y].spot.Count; x++)
            {
                var currentSpot = v2(x, y);

                if (HasUnit(currentSpot))
                {
                    continue;
                }
                if (IsBlocked(currentSpot))
                {
                    continue;
                }


                AssignPosition(AI, currentSpot);

                return;
            }
        }

        AddBackLine(width);
        AssignPosition(AI, v2(0, line.Count));
    }
Пример #3
0
    private Unit InternalCreateUnit()
    {
        Infantry infantry = new Infantry(this, unitBuildChoiceProvider);

        infantry.CreatePlacebleModel();
        return(infantry);
    }
Пример #4
0
 public State(Spies spy, Infantry inf, Tanks tank, Jets jet, Bombers bomb, Sams sam, Ships ship)
 {
     this.Spy          = spy;
     this.Inf          = inf;
     this.Tank         = tank;
     this.Jet          = jet;
     this.Bomb         = bomb;
     this.Sam          = sam;
     this.Ship         = ship;
     this.UserAttPwr   = this.Inf.InfAttPwr + this.Tank.TankAttPwr + this.Jet.JetAttPwr + this.Bomb.BombAttPwr + this.Ship.ShipAttPwr;
     this.UserGADefPwr = this.Inf.InfAttPwr + this.Tank.TankAttPwr;
     this.UserARDefPwr = this.Jet.JetAttPwr + this.Sam.SamAttPwr;
     this.UserAADefPwr = this.Ship.ShipAttPwr;
     this.UserDefPwr   = this.Inf.InfAttPwr + this.Tank.TankAttPwr + this.Sam.SamAttPwr + this.Ship.ShipAttPwr;
     this.UserGbAttPwr = (this.Spy.SpyUserPwr * this.Spy.SpyCount) + (this.Jet.JetUserPwr * this.Jet.JetCount) + (this.Bomb.BombUserPwr * this.Bomb.BombCount);
     this.userGbDefPwr = (this.Inf.InfUserPwr * this.Inf.InfCount) + (this.Tank.TankUserPwr * this.Tank.TankCount) + (this.Sam.SamUserPwr * this.Sam.SamCount) + (this.Ship.ShipUserPwr * this.Ship.ShipCount);
     if (this.UserGbAttPwr > this.userGbDefPwr)
     {
         this.GbProtection = "No";
     }
     else
     {
         this.GbProtection = "Yes";
     }
     this.Readiness = 0;
 }
Пример #5
0
 public Flank(int inf, int cav, int arch)
 {
     this.inf        = new Infantry(inf);
     this.cav        = new Cavalry(cav);
     this.arch       = new Archer(arch);
     this.max_morale = this.inf.GetMorale() + this.cav.GetMorale() + this.arch.GetMorale();
     this.morale     = max_morale;
 }
 void Awake()
 {
     healer   = GetComponent <Healer>();
     infantry = GetComponent <Infantry>();
     knight   = GetComponent <Knight>();
     mage     = GetComponent <Mage>();
     spy      = GetComponent <Spy>();
 }
Пример #7
0
    static void update(Transform Trnsfrm, Rigidbody2D Body, Infantry U, ref int SPi, ref bool PathActive) {

        Vector2 Pos = Body.position, Vel = Body.velocity;
        float Ang = Body.rotation;
        float AngVel = Body.angularVelocity;
        Vector2 Fwd = new Vector2(-Mathf.Sin(Ang * Mathf.Deg2Rad), Mathf.Cos(Ang * Mathf.Deg2Rad));
        Vector2 Vec = U.SmoothPath[SPi] - Pos;
        float Mag = Vec.magnitude;
        
        if(PathActive) {
            for(; ; ) {
                if(SPi < U.SmoothPath.Count - 1) {
                    var v2 = U.SmoothPath[SPi + 1] - Pos;
                    if(Vector2.Dot(Vec, v2) < -0.1f) {
                        SPi++;
                        Vec = v2;
                    } else {
                        Mag = Vec.magnitude;
                        break;
                    }
                } else {
                    Mag = Vec.magnitude;
                    if(Mag < U.RoughRadius *0.75 )
                        PathActive = false;
                    break;
                }
            }

            Mag *= 2; Vec *= 2;

            for(; ; ) {
                if(Mag > U.MaxSpeed) {

                    Vec = Vec * U.MaxSpeed / Mag;
                    break;
                }
                if(SPi >= U.SmoothPath.Count - 1) break;
                var v2 = U.SmoothPath[SPi + 1] - U.SmoothPath[SPi];
                var vn = Vec / Mag;
                float dt2 = Vector2.Dot(v2, vn);
                if(dt2 > 0) {
                    Mag += dt2;
                    Vec = vn * Mag;
                } else break;
            }
            Body.velocity = Vector2.Lerp(Body.velocity, Vec, U.Acceleration * Time.deltaTime);

            var dy = Mathf.Rad2Deg * Mathf.Atan2(-Vec.x, Vec.y);
            Body.MoveRotation(Mathf.LerpAngle(Ang, Mathf.MoveTowardsAngle(Ang, dy, 1080 * Time.deltaTime), U.MaxTurnSpeed * Time.deltaTime));
        } else {
            if(U.FireTarget != null) {
                Body.MoveRotation(Mathf.LerpAngle(Ang, Mathf.MoveTowardsAngle(Ang, U.TargetAng, 1080 * Time.deltaTime), U.MaxTurnSpeed * Time.deltaTime));
            }
            Body.velocity = Vector2.Lerp(Body.velocity, Vector2.zero, 1.5f *U.Acceleration * Time.deltaTime);
        }         
    }
Пример #8
0
 public void UpdateAI(Infantry AI)
 {
     for (int y = 0; y < line.Count; y++)
     {
         for (int x = 0; x < line [y].spot.Count; x++)
         {
             if (ReferenceEquals(AI, line[y].spot[x].AI))
             {
                 AI.UpdateSpot(v2(x, y));
             }
         }
     }
 }
    // Create new character
    public void newInfantry(string sfact)
    {
        CharCount++;
        Character inf = new Infantry(sfact);

        inf.C_DeployID  = CharCount;
        inf.CharPanel   = CharacterPrefab;
        inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/" + sfact);
        inf.RankIcon    = FactionManager.control.getRankIcon(inf.Rank.ToString());

        FactionManager.control.Factions [sfact].Characters.Add(inf);
        FactionManager.control.Factions [sfact].TotalOwnedCharInf += 1;

        ////Debug.Log ("A New " + sfact + " Infantry is added. id:_" + inf.C_ID.ToString());
    }
Пример #10
0
        static void Main(string[] args)
        {
            var samurai = new Samurai();

            samurai.Attack();

            var grenadier = new Grenadier();

            grenadier.Attack();

            var infantry = new Infantry();

            infantry.Attack();

            Console.Read();
        }
Пример #11
0
        static void Main()
        {
            var stormCommander = new Commander();
            var infantry       = new Infantry();


            var stormCommander2 = stormCommander.Clone() as Commander;
            var infantry2       = infantry.Clone() as Infantry;


            if (stormCommander2 != null)
            {
                Console.WriteLine("Firepower: {0}, Armor: {1}", stormCommander2.FirePower, stormCommander2.Armor);
            }

            if (infantry2 != null)
            {
                Console.WriteLine("Firepower: {0}, Armor: {1}", infantry2.FirePower, infantry2.Armor);
            }
        }
        public void RecruitInfantry()
        {
            var faction = new Infantry();
            var counter = 0;

            for (var i = 0; i < 500; i++)
            {
                var soldier = new RebelSoldier();
                if (counter > 3)
                {
                    soldier.Weapon = new BlasterRifle();
                    counter++;
                }
                else
                {
                    soldier.Weapon = faction.StandardIssueWeapon;
                    counter        = 0;
                }
                faction.Soldiers.Add(soldier);
            }
            Legion.Factions.Add(faction);
        }
Пример #13
0
    void searchPro()
    {
        _animations.SetBool("Range", false);

        Vector3 explosionPos = transform.position;

        Collider[] colliders = Physics.OverlapSphere(explosionPos, 50);

        foreach (Collider hit in colliders)
        {
            if (hit.gameObject.tag == "EnemyS")
            {
                troop = hit.gameObject.GetComponent <Infantry>();
                if (troop.status() < 30)
                {
                    troop.begin(0, this.gameObject);
                }
                _estado = estados.protect;
                break;
            }
        }
    }
Пример #14
0
    public void calcGABreak(double tempGADefPwr)
    {
        Infantry inf = new Infantry(0, 1, 0);

        lblWarInfLvl1Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / inf.InfUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        inf = new Infantry(0, 2, 0);
        lblWarInfLvl2Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / inf.InfUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        inf = new Infantry(0, 3, 0);
        lblWarInfLvl3Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / inf.InfUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        inf = new Infantry(0, 4, 0);
        lblWarInfLvl4Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / inf.InfUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        inf = new Infantry(0, 5, 0);
        lblWarInfLvl5Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / inf.InfUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        inf = new Infantry(0, 6, 0);
        lblWarInfLvl6Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / inf.InfUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        inf = new Infantry(0, 7, 0);
        lblWarInfLvl7Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / inf.InfUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        inf = new Infantry(0, 8, 0);
        lblWarInfLvl8Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / inf.InfUserPwr)) / 1.5, 0).ToString("###,###,###,###");

        Tanks tank = new Tanks(0, 1, 0);

        lblWarTankLvl1Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / tank.TankUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        tank = new Tanks(0, 2, 0);
        lblWarTankLvl2Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / tank.TankUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        tank = new Tanks(0, 3, 0);
        lblWarTankLvl3Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / tank.TankUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        tank = new Tanks(0, 4, 0);
        lblWarTankLvl4Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / tank.TankUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        tank = new Tanks(0, 5, 0);
        lblWarTankLvl5Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / tank.TankUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        tank = new Tanks(0, 6, 0);
        lblWarTankLvl6Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / tank.TankUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        tank = new Tanks(0, 7, 0);
        lblWarTankLvl7Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / tank.TankUserPwr)) / 1.5, 0).ToString("###,###,###,###");
        tank = new Tanks(0, 8, 0);
        lblWarTankLvl8Count.Text = Math.Round(Math.Ceiling((tempGADefPwr / tank.TankUserPwr)) / 1.5, 0).ToString("###,###,###,###");
    }
Пример #15
0
    void formUp()
    {
        Vector3 explosionPos = transform.position;

        Collider[] colliders = Physics.OverlapSphere(explosionPos, 50);

        _estado = estados.bajoOrdenes;

        foreach (Collider hit in colliders)
        {
            if (hit.gameObject.tag == "EnemyS")
            {
                troop = hit.gameObject.GetComponent <Infantry>();

                if (troop.begin(numeroSoldado, this.gameObject))
                {
                    unidades.Add(troop.gameObject);
                    numeroSoldado++;
                }
            }

            if (hit.gameObject.tag == "ArmoredE")
            {
                sTroop = hit.gameObject.GetComponent <Shield>();

                if (sTroop.begin(numeroEscudo, this.gameObject))
                {
                    unidades.Add(sTroop.gameObject);
                    numeroEscudo++;
                }
            }
        }

        onOrder = true;
        check();
    }
//	public void checkATdeployed(string sfact){
//	}

    public void GetCharData()
    {
        foreach (CharacterData cd in S_Characterdata)
        {
            if (cd.Type == Character.C_Type.InfantryMan)
            {
                CharacterManager.characterManager.CharCount++;
                Character inf = new Infantry(cd.Faction.ToString());
                inf.C_ID       = cd.C_ID;
                inf.C_Name     = cd.C_Name;
                inf.C_DeployID = cd.C_DeployID;
                inf.CharPanel  = CharacterManager.characterManager.CharacterPrefab;
                if (cd.Faction == Character.C_Faction.US)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/US");
                }
                else if (cd.Faction == Character.C_Faction.GERMANY)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/GERMANY");
                }
                else if (cd.Faction == Character.C_Faction.SOVIET)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/SOVIET");
                }


                inf.Rank     = cd.Rank;
                inf.RankIcon = FactionManager.control.getRankIcon(inf.Rank.ToString());

                inf.IsSelected = cd.IsSelected;
                inf.hasDeploy  = cd.hasDeployed;
                //inf.AssaultTeamsDeployed = cd.AssaultTeamsDeployed;
                inf.CommandPoints       = cd.CommandPoints;
                inf.CommandActivePoints = cd.CommandActivePoints;

                FactionManager.control.Factions [cd.Faction.ToString()].Characters.Add(inf);
                FactionManager.control.Factions [cd.Faction.ToString()].TotalOwnedCharInf += 1;
            }
            else if (cd.Type == Character.C_Type.Para)
            {
                CharacterManager.characterManager.CharCount++;
                Character inf = new Para(cd.Faction.ToString());
                inf.C_ID       = cd.C_ID;
                inf.C_Name     = cd.C_Name;
                inf.C_DeployID = cd.C_DeployID;
                inf.CharPanel  = CharacterManager.characterManager.CharacterPrefab;
                if (cd.Faction == Character.C_Faction.US)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/US");
                }
                else if (cd.Faction == Character.C_Faction.GERMANY)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/GERMANY");
                }
                else if (cd.Faction == Character.C_Faction.SOVIET)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/SOVIET");
                }

                inf.Rank     = cd.Rank;
                inf.RankIcon = FactionManager.control.getRankIcon(inf.Rank.ToString());

                inf.IsSelected          = cd.IsSelected;
                inf.hasDeploy           = cd.hasDeployed;
                inf.CommandPoints       = cd.CommandPoints;
                inf.CommandActivePoints = cd.CommandActivePoints;
                //inf.AssaultTeamsDeployed = cd.AssaultTeamsDeployed;


                FactionManager.control.Factions [cd.Faction.ToString()].Characters.Add(inf);
                FactionManager.control.Factions [cd.Faction.ToString()].TotalOwnedCharPar += 1;
            }
            else if (cd.Type == Character.C_Type.Recon)
            {
                CharacterManager.characterManager.CharCount++;
                Character inf = new Recon(cd.Faction.ToString());
                inf.C_ID       = cd.C_ID;
                inf.C_Name     = cd.C_Name;
                inf.C_DeployID = cd.C_DeployID;
                inf.CharPanel  = CharacterManager.characterManager.CharacterPrefab;
                if (cd.Faction == Character.C_Faction.US)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/US");
                }
                else if (cd.Faction == Character.C_Faction.GERMANY)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/GERMANY");
                }
                else if (cd.Faction == Character.C_Faction.SOVIET)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/SOVIET");
                }

                inf.Rank     = cd.Rank;
                inf.RankIcon = FactionManager.control.getRankIcon(inf.Rank.ToString());

                inf.IsSelected          = cd.IsSelected;
                inf.hasDeploy           = cd.hasDeployed;
                inf.CommandPoints       = cd.CommandPoints;
                inf.CommandActivePoints = cd.CommandActivePoints;
                //inf.AssaultTeamsDeployed = cd.AssaultTeamsDeployed;


                FactionManager.control.Factions [cd.Faction.ToString()].Characters.Add(inf);
                FactionManager.control.Factions [cd.Faction.ToString()].TotalOwnedCharRec += 1;
            }
            else if (cd.Type == Character.C_Type.TankMan)
            {
                CharacterManager.characterManager.CharCount++;
                Character inf = new Tankman(cd.Faction.ToString());
                inf.C_ID       = cd.C_ID;
                inf.C_Name     = cd.C_Name;
                inf.C_DeployID = cd.C_DeployID;
                inf.CharPanel  = CharacterManager.characterManager.CharacterPrefab;
                if (cd.Faction == Character.C_Faction.US)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/US");
                }
                else if (cd.Faction == Character.C_Faction.GERMANY)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/GERMANY");
                }
                else if (cd.Faction == Character.C_Faction.SOVIET)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/SOVIET");
                }

                inf.Rank     = cd.Rank;
                inf.RankIcon = FactionManager.control.getRankIcon(inf.Rank.ToString());

                inf.IsSelected          = cd.IsSelected;
                inf.hasDeploy           = cd.hasDeployed;
                inf.CommandPoints       = cd.CommandPoints;
                inf.CommandActivePoints = cd.CommandActivePoints;
                //inf.AssaultTeamsDeployed = cd.AssaultTeamsDeployed;


                FactionManager.control.Factions [cd.Faction.ToString()].Characters.Add(inf);
                FactionManager.control.Factions [cd.Faction.ToString()].TotalOwnedCharTan += 1;
            }
            else if (cd.Type == Character.C_Type.Pilot)
            {
                CharacterManager.characterManager.CharCount++;
                Character inf = new Pilot(cd.Faction.ToString());
                inf.C_ID       = cd.C_ID;
                inf.C_Name     = cd.C_Name;
                inf.C_DeployID = cd.C_DeployID;
                inf.CharPanel  = CharacterManager.characterManager.CharacterPrefab;
                if (cd.Faction == Character.C_Faction.US)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/US");
                }
                else if (cd.Faction == Character.C_Faction.GERMANY)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/GERMANY");
                }
                else if (cd.Faction == Character.C_Faction.SOVIET)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/SOVIET");
                }

                inf.Rank     = cd.Rank;
                inf.RankIcon = FactionManager.control.getRankIcon(inf.Rank.ToString());

                inf.IsSelected          = cd.IsSelected;
                inf.hasDeploy           = cd.hasDeployed;
                inf.CommandPoints       = cd.CommandPoints;
                inf.CommandActivePoints = cd.CommandActivePoints;
                //inf.AssaultTeamsDeployed = cd.AssaultTeamsDeployed;


                FactionManager.control.Factions [cd.Faction.ToString()].Characters.Add(inf);
                FactionManager.control.Factions [cd.Faction.ToString()].TotalOwnedCharPil += 1;
            }
            else if (cd.Type == Character.C_Type.General)
            {
                CharacterManager.characterManager.CharCount++;
                Character inf = new General(cd.Faction.ToString());
                inf.C_ID       = cd.C_ID;
                inf.C_Name     = cd.C_Name;
                inf.C_DeployID = cd.C_DeployID;
                inf.CharPanel  = CharacterManager.characterManager.CharacterPrefab;
                if (cd.Faction == Character.C_Faction.US)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/US");
                }
                else if (cd.Faction == Character.C_Faction.GERMANY)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/GERMANY");
                }
                else if (cd.Faction == Character.C_Faction.SOVIET)
                {
                    inf.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/SOVIET");
                }

                inf.Rank     = cd.Rank;
                inf.RankIcon = FactionManager.control.getRankIcon(inf.Rank.ToString());

                inf.IsSelected          = cd.IsSelected;
                inf.hasDeploy           = cd.hasDeployed;
                inf.CommandPoints       = cd.CommandPoints;
                inf.CommandActivePoints = cd.CommandActivePoints;
                //inf.AssaultTeamsDeployed = cd.AssaultTeamsDeployed;


                FactionManager.control.Factions [cd.Faction.ToString()].Characters.Add(inf);
                FactionManager.control.Factions [cd.Faction.ToString()].TotalOwnedCharGen += 1;
            }
            else
            {
                return;
            }
            //Debug.LogError ("testercheck " + cd.AssaultTeamsDeployed.Count);
        }
    }
Пример #17
0
    public void FillWarEnemyInformation(object sender, Boolean recalculate = false)
    {
        if (defWarArmyInfo.Text.Length > 0)
        {
            string str    = defWarArmyInfo.Text;
            Regex  espRgx = new Regex("Espionage");
            Match  match;

            match = espRgx.Match(str);
            if (match.Success)
            {
                try
                {
                    double readiness = 0;
                    if (!recalculate)
                    {
                        string segment;
                        Regex  rgx = new Regex("[0-9]+\\.*[0-9]*\\.*[0-9]*");

                        int startChar;
                        int endChar;


                        // Find State Name and Cut String
                        string stateStr = "State: ";
                        startChar = str.IndexOf(stateStr);
                        string readyStr = "Readiness";
                        endChar = str.IndexOf(readyStr);
                        lblWarStateName.Text = str.Substring(startChar + stateStr.Length, endChar - startChar - stateStr.Length).Trim();
                        segment = str.Substring(endChar + readyStr.Length, str.Length - (endChar + readyStr.Length));

                        match = rgx.Match(segment);

                        #region Get Readiness
                        if (match.Success)
                        {
                            startChar = segment.IndexOf(match.Value);

                            if (tbWarEnemyReadiness.Text.Length > 0)
                            {
                                readiness = Convert.ToDouble(tbWarEnemyReadiness.Text.Replace("%", "").Trim()) / 100;
                                if (readiness == 0)
                                {
                                    tbWarEnemyReadiness.Text = "0%";
                                }
                                else
                                {
                                    tbWarEnemyReadiness.Text = readiness.ToString("###%");
                                }
                            }
                            else
                            {
                                readiness = Convert.ToDouble(match.Value.Replace(".", ",").Trim()) / 100;
                                tbWarEnemyReadiness.Text = readiness.ToString("###%");
                            }
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        #endregion

                        //Get to the troop info
                        startChar = str.IndexOf("Spies");
                        segment   = str.Substring(startChar, (str.Length - startChar));
                        match     = rgx.Match(segment);

                        #region Gather Enemy Spies Info
                        if (match.Success)
                        {
                            startChar             = segment.IndexOf(match.Value);
                            tbWarDefSpyCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar = segment.IndexOf(match.Value);
                            tbWarDefNaSpyCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar            = segment.IndexOf(match.Value);
                            lblWarDefSpyLvl.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        #endregion

                        #region Gather Enemy Infantry Info
                        if (match.Success)
                        {
                            startChar             = segment.IndexOf(match.Value);
                            tbWarDefInfCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar = segment.IndexOf(match.Value);
                            tbWarDefNaInfCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar            = segment.IndexOf(match.Value);
                            lblWarDefInfLvl.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        #endregion

                        #region Gather Enemy Tanks Info
                        if (match.Success)
                        {
                            startChar = segment.IndexOf(match.Value);
                            tbWarDefTankCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar = segment.IndexOf(match.Value);
                            tbWarDefNaTankCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar             = segment.IndexOf(match.Value);
                            lblWarDefTankLvl.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        #endregion

                        #region Gather Enemy Jets Info
                        if (match.Success)
                        {
                            startChar             = segment.IndexOf(match.Value);
                            tbWarDefJetCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar = segment.IndexOf(match.Value);
                            tbWarDefNaJetCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar            = segment.IndexOf(match.Value);
                            lblWarDefJetLvl.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        #endregion

                        #region Gather Enemy Bombers Info
                        if (match.Success)
                        {
                            startChar = segment.IndexOf(match.Value);
                            tbWarDefBombCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar = segment.IndexOf(match.Value);
                            tbWarDefNaBombCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar             = segment.IndexOf(match.Value);
                            lblWarDefBombLvl.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        #endregion

                        #region Gather Enemy SAMS Info
                        if (match.Success)
                        {
                            startChar             = segment.IndexOf(match.Value);
                            tbWarDefSamCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar = segment.IndexOf(match.Value);
                            tbWarDefNaSamCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar            = segment.IndexOf(match.Value);
                            lblWarDefSamLvl.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        #endregion

                        #region Gather Enemy Ships Info
                        if (match.Success)
                        {
                            startChar = segment.IndexOf(match.Value);
                            tbWarDefShipCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar = segment.IndexOf(match.Value);
                            tbWarDefNaShipCount.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        if (match.Success)
                        {
                            startChar             = segment.IndexOf(match.Value);
                            lblWarDefShipLvl.Text = match.Value.Replace(".", ",").Trim();
                            segment = segment.Substring(startChar + match.Value.Length);
                            match   = rgx.Match(segment);
                        }
                        #endregion
                    }
                    else
                    {
                        tbWarDefSpyCount.Text    = Convert.ToInt32(tbWarDefSpyCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        tbWarDefNaSpyCount.Text  = Convert.ToInt32(tbWarDefNaSpyCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        tbWarDefInfCount.Text    = Convert.ToInt32(tbWarDefInfCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        tbWarDefNaInfCount.Text  = Convert.ToInt32(tbWarDefNaInfCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        tbWarDefTankCount.Text   = Convert.ToInt32(tbWarDefTankCount.Text.Replace(",", "").Insert(0, "0")).ToString("#0");
                        tbWarDefNaTankCount.Text = Convert.ToInt32(tbWarDefNaTankCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        tbWarDefJetCount.Text    = Convert.ToInt32(tbWarDefJetCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        tbWarDefNaJetCount.Text  = Convert.ToInt32(tbWarDefNaJetCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        tbWarDefBombCount.Text   = Convert.ToInt32(tbWarDefBombCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        tbWarDefNaBombCount.Text = Convert.ToInt32(tbWarDefNaBombCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        tbWarDefSamCount.Text    = Convert.ToInt32(tbWarDefSamCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        tbWarDefNaSamCount.Text  = Convert.ToInt32(tbWarDefNaSamCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        tbWarDefShipCount.Text   = Convert.ToInt32(tbWarDefShipCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        tbWarDefNaShipCount.Text = Convert.ToInt32(tbWarDefNaShipCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0");
                        readiness = Convert.ToDouble(tbWarEnemyReadiness.Text.Replace("%", "").Trim()) / 100;
                        tbWarEnemyReadiness.Text = readiness.ToString("###%");
                    }

                    #region Create Enemy State

                    Spies    spy  = new Spies(Convert.ToInt32(tbWarDefSpyCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefSpyLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaSpyCount.Text.ToString().Replace(",", "")));
                    Infantry inf  = new Infantry(Convert.ToInt32(tbWarDefInfCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefInfLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaInfCount.Text.ToString().Replace(",", "")));
                    Tanks    tank = new Tanks(Convert.ToInt32(tbWarDefTankCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefTankLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaTankCount.Text.ToString().Replace(",", "")));
                    Jets     jet  = new Jets(Convert.ToInt32(tbWarDefJetCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefJetLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaJetCount.Text.ToString().Replace(",", "")));
                    Bombers  bomb = new Bombers(Convert.ToInt32(tbWarDefBombCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefBombLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaBombCount.Text.ToString().Replace(",", "")));
                    Sams     sam  = new Sams(Convert.ToInt32(tbWarDefSamCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefSamLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaSamCount.Text.ToString().Replace(",", "")));
                    Ships    ship = new Ships(Convert.ToInt32(tbWarDefShipCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefShipLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaShipCount.Text.ToString().Replace(",", "")));

                    State enemyState = new State(spy, inf, tank, jet, bomb, sam, ship);
                    enemyState.Readiness     = readiness;
                    enemyState.UserDefPwr   *= enemyState.Readiness;
                    enemyState.UserGADefPwr *= enemyState.Readiness;
                    enemyState.UserARDefPwr *= enemyState.Readiness;
                    enemyState.UserAADefPwr *= enemyState.Readiness;

                    if (enemyState.UserGADefPwr == 0)
                    {
                        lblWarGADefPwr.Text = "0";
                    }
                    else
                    {
                        lblWarGADefPwr.Text = enemyState.UserGADefPwr.ToString("###,###,###,###");
                    }

                    if (enemyState.UserARDefPwr == 0)
                    {
                        lblWarARDefPwr.Text = "0";
                    }
                    else
                    {
                        lblWarARDefPwr.Text = enemyState.UserARDefPwr.ToString("###,###,###,###");
                    }

                    if (enemyState.UserAADefPwr == 0)
                    {
                        lblWarAADefPwr.Text = "0";
                    }
                    else
                    {
                        lblWarAADefPwr.Text = enemyState.UserAADefPwr.ToString("###,###,###,###");
                    }
                    #endregion

                    if (defWarArmyInfo.Text.Length > 0)
                    {
                        calcWarBreaks();
                    }
                }
                catch
                {
                    //clearWarEnemyInfo();
                }
            }
            else
            {
                //clearWarEnemyInfo();
            }
        }
    }
Пример #18
0
        public void TestMethod2()
        {
            BaseUnitType gUnit = new Infantry();
            var          inf1  = new Infantry();
            var          inf2  = new Infantry();
            var          inf3  = new Infantry();

            var eng1 = new Engineer();
            var eng2 = new Engineer();
            var eng3 = new Engineer();

            var scout1 = new Scout();
            var scout2 = new Scout();
            var scout3 = new Scout();

            var mar1 = new Marine();
            var mar2 = new Marine();
            var mar3 = new Marine();

            var light1 = new Light();
            var light2 = new Light();
            var light3 = new Light();

            var heavy1 = new Heavy();
            var heavy2 = new Heavy();
            var heavy3 = new Heavy();

            var mort1 = new Mortar();
            var mort2 = new Mortar();
            var mort3 = new Mortar();

            var art1 = new Artillery();
            var art2 = new Artillery();
            var art3 = new Artillery();

            var air1 = new Airborn();
            var air2 = new Airborn();
            var air3 = new Airborn();

            var snip1 = new Sniper();
            var snip2 = new Sniper();
            var snip3 = new Sniper();

            inf1.Dispose();
            eng2.Dispose();
            scout1.Dispose();
            mar3.Dispose();
            light2.Dispose();
            heavy1.Dispose();
            mort3.Dispose();
            art2.Dispose();
            air3.Dispose();
            snip1.Dispose();

            inf1.DisplayString();
            inf2.DisplayString();
            inf3.DisplayString();
            eng1.DisplayString();
            eng2.DisplayString();
            eng3.DisplayString();
            scout1.DisplayString();
            scout2.DisplayString();
            scout3.DisplayString();
            mar1.DisplayString();
            mar2.DisplayString();
            mar3.DisplayString();
            light1.DisplayString();
            light2.DisplayString();
            light3.DisplayString();
            heavy1.DisplayString();
            heavy2.DisplayString();
            heavy3.DisplayString();
            mort1.DisplayString();
            mort2.DisplayString();
            mort3.DisplayString();
            art1.DisplayString();
            art2.DisplayString();
            art3.DisplayString();
            air1.DisplayString();
            air2.DisplayString();
            air3.DisplayString();
            snip1.DisplayString();
            snip2.DisplayString();
            snip3.DisplayString();
        }
Пример #19
0
        public static (Rectangle, Action <Graphics>) Render(TheaterType theater, Point topLeft, Size tileSize, Infantry infantry, InfantryStoppingType infantryStoppingType)
        {
            var icon = HumanShape[Facing32[infantry.Direction.ID]];

            string teamColor = infantry.House?.UnitTeamColor;

            if (Globals.TheTilesetManager.GetTeamColorTileData(theater.Tilesets, infantry.Type.Name, icon, Globals.TheTeamColorManager[teamColor], out Tile tile))
            {
                var baseLocation = new Point(topLeft.X * tileSize.Width, topLeft.Y * tileSize.Height)
                                   + new Size(tileSize.Width / 2, tileSize.Height / 2);

                var offset = Point.Empty;
                switch (infantryStoppingType)
                {
                case InfantryStoppingType.UpperLeft:
                    offset.X = -tileSize.Width / 4;
                    offset.Y = -tileSize.Height / 4;
                    break;

                case InfantryStoppingType.UpperRight:
                    offset.X = tileSize.Width / 4;
                    offset.Y = -tileSize.Height / 4;
                    break;

                case InfantryStoppingType.LowerLeft:
                    offset.X = -tileSize.Width / 4;
                    offset.Y = tileSize.Height / 4;
                    break;

                case InfantryStoppingType.LowerRight:
                    offset.X = tileSize.Width / 4;
                    offset.Y = tileSize.Height / 4;
                    break;
                }
                baseLocation.Offset(offset);

                var virtualBounds = new Rectangle(
                    new Point(baseLocation.X - (tile.OpaqueBounds.Width / 2), baseLocation.Y - tile.OpaqueBounds.Height),
                    tile.OpaqueBounds.Size
                    );
                var renderBounds = new Rectangle(
                    baseLocation - new Size(infantry.Type.RenderSize.Width / 2, infantry.Type.RenderSize.Height / 2),
                    infantry.Type.RenderSize
                    );

                var tint = infantry.Tint;
                void render(Graphics g)
                {
                    var imageAttributes = new ImageAttributes();

                    if (tint != Color.White)
                    {
                        var colorMatrix = new ColorMatrix(new float[][]
                        {
                            new float[] { tint.R / 255.0f, 0, 0, 0, 0 },
                            new float[] { 0, tint.G / 255.0f, 0, 0, 0 },
                            new float[] { 0, 0, tint.B / 255.0f, 0, 0 },
                            new float[] { 0, 0, 0, tint.A / 255.0f, 0 },
                            new float[] { 0, 0, 0, 0, 1 },
                        }
                                                          );
                        imageAttributes.SetColorMatrix(colorMatrix);
                    }
                    g.DrawImage(tile.Image, renderBounds, 0, 0, tile.Image.Width, tile.Image.Height, GraphicsUnit.Pixel, imageAttributes);
                }

                return(virtualBounds, render);
            }
            else
            {
                Debug.Print(string.Format("Infantry {0} ({1}) not found", infantry.Type.Name, icon));
                return(Rectangle.Empty, (g) => { });
            }
        }
Пример #20
0
 // Use this for initialization
 void Start()
 {
     anim = GetComponentInChildren <Animator> ();
     AI   = GetComponent <Infantry> ();
 }
Пример #21
0
 public Spot(Infantry newAI, Vector3 newPosition)
 {
     AI       = newAI;
     position = newPosition;
 }
Пример #22
0
 void AssignPosition(Infantry AI, Vector2Int index)
 {
     line [index.y].spot [index.x].AI = AI;
     line [index.y].spot [index.x].AI.UpdateSpot(index);
     //AI.AIBox.transform.position = line[index.y].spot[index.x].position;
 }
Пример #23
0
        public void UIField()
        {
            Coordinate?addCoordinate = null;

            bool isToTrain = false;

            int numberOfUnitsToProduce = 0;

            string errorMessage = null;
            string option, coordinate = null;
            string strBuilding        = null;
            string unit               = null;
            string unitToTrain        = null;
            string optionalCoordinate = null;
            string isNewTurn          = null;

            Field field = new Field(gm);

            field.Show();
            int n_moves = 0;

            if (gm.PlayerTurn == null)
            {
                gm.PlayerTurn = gm.Player1;
            }


            do
            {
                if (isNewTurn == null)
                {
                    n_moves = gm.PlayerTurn.Resources.N_Moves;
                }
                else if (isNewTurn == "YES")
                {
                    n_moves = gm.PlayerTurn.Resources.N_Moves;
                }

                int nBarracks           = gm.PlayerTurn.Resources.CountBarracks();
                int nStables            = gm.PlayerTurn.Resources.CountStables();
                int nArtilleryFactories = gm.PlayerTurn.Resources.CountArtilleryFactories();

                Console.WriteLine("────────────────────────────────────────────");
                Console.ForegroundColor = gm.PlayerTurn.Color;
                Console.WriteLine("{0} its your turn", gm.PlayerTurn.Username);
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("You have {0} points to move", n_moves);
                Console.WriteLine("You have {0} coins", gm.PlayerTurn.Resources.Coins);
                Console.ResetColor();
                Console.WriteLine("────────────────────────────────────────────");
                Console.WriteLine("What is your next move?");
                Console.WriteLine("────────────────────────────────────────────");
                Console.WriteLine("ADD");
                if (nBarracks > 0 || nStables > 0 || nArtilleryFactories > 0)
                {
                    Console.WriteLine("TRAIN UNITS");
                }
                Console.WriteLine("MOVE");
                Console.WriteLine("ATTACK");
                Console.WriteLine("────────────────────────────────────────────");
                option = Console.ReadLine().ToUpper();



                if (option == "ADD")
                {
                    if (gm.PlayerTurn.Resources.HasAnyKindOfUnit())
                    {
                        Console.WriteLine("If you want to add a unit you don't need to specify the coordinate, you can write: b,2");
                    }
                    Console.WriteLine("Which coordinate do you want to add? Ex:(letter,number)");
                    coordinate = Console.ReadLine().ToUpper();



                    //TODO: Needs a try here
                    try
                    {
                        string[] coordinateSplit = coordinate.Split(',');

                        char letter = Convert.ToChar(coordinateSplit[0]);
                        int  number = Int32.Parse(coordinateSplit[1]);

                        addCoordinate = new Coordinate(letter, number);
                    }
                    catch (FormatException e)
                    {
                        Utils.ColorWrite(ConsoleColor.Red, "You need to write letter,number");
                        Console.WriteLine();
                    }
                }
                else if (option == "TRAIN UNITS")
                {
                    isToTrain = true;
                }
                else if (option == "MOVE" || option == "ATTACK")
                {
                    string firstTextMoveOrAttack = option == "MOVE"
                        ? "Which coordinate do you want to move? Ex:(letter,number)"
                        : "Select the unit that you want to attack with! (letter,number)";
                    string secondTextMoveOrAttack = option == "MOVE"
                        ? "Where do you want to replace it? Ex:(letter,number)"
                        : "Select the unit that you want to attack! (letter,number)";

                    Console.WriteLine(firstTextMoveOrAttack);
                    coordinate = Console.ReadLine().ToUpper();

                    try
                    {
                        string[] coordinateSplit = coordinate.Split(',');

                        char letter = Convert.ToChar(coordinateSplit[0]);
                        int  number = Int32.Parse(coordinateSplit[1]);

                        addCoordinate = new Coordinate(letter, number);

                        Console.WriteLine(secondTextMoveOrAttack);

                        optionalCoordinate = Console.ReadLine().ToUpper();
                    }
                    catch (FormatException e)
                    {
                        Utils.ColorWrite(ConsoleColor.Red, "You need to write letter,number");
                        Console.WriteLine();
                    }
                }
                else if (option == "EXIT")
                {
                    break;
                }

                if (isToTrain)
                {
                    Console.WriteLine("SELECT ONE OF THIS UNITS TO TRAIN");
                    Console.WriteLine("────────────────────────────────────────────");
                    if (nBarracks > 0)
                    {
                        Console.WriteLine("INFANTRY | You got {0}", gm.PlayerTurn.Resources.N_Infantry);
                    }
                    if (nStables > 0)
                    {
                        Console.WriteLine("CAVALRY  | You got {0}", gm.PlayerTurn.Resources.N_Cavalry);
                    }
                    if (nArtilleryFactories > 0)
                    {
                        Console.WriteLine("ARTILLERY| You got {0}", gm.PlayerTurn.Resources.N_Artillery);
                    }
                    Console.WriteLine("────────────────────────────────────────────");
                    unitToTrain = Console.ReadLine().ToUpper();

                    Console.WriteLine("How many units you want?");
                    numberOfUnitsToProduce = int.Parse(Console.ReadLine());
                }
                else if (optionalCoordinate == null && addCoordinate.HasValue)
                {
                    Console.WriteLine("Which type of unit you want to add?");
                    Console.WriteLine("────────────────────────────────────────────");
                    Console.WriteLine("BUILDING");
                    if (gm.PlayerTurn.Resources.HasAnyKindOfUnit())
                    {
                        Console.WriteLine("UNIT");
                    }
                    Console.WriteLine("────────────────────────────────────────────");

                    string isBuildingString = Console.ReadLine().ToUpper();
                    bool   isBuilding       = isBuildingString == "BUILDING" ? true : false;

                    if (isBuilding)
                    {
                        Console.WriteLine("SELECT ONE OF THIS BUILDINGS TO BUILD!");
                        Console.WriteLine("────────────────────────────────────────────");
                        Console.WriteLine("FARM");
                        Console.WriteLine("BARRACK");
                        Console.WriteLine("STABLE");
                        Console.WriteLine("ARTILLERY FACTORY");
                        Console.WriteLine("────────────────────────────────────────────");
                        strBuilding = Console.ReadLine().ToUpper();
                    }
                    else if (gm.PlayerTurn.Resources.HasAnyKindOfUnit())
                    {
                        Console.WriteLine("SELECT ONE OF THIS UNITS TO SPAWN");
                        Console.WriteLine("────────────────────────────────────────────");
                        Console.WriteLine("INFANTRY | You got {0}", gm.PlayerTurn.Resources.N_Infantry);
                        Console.WriteLine("CAVALRY  | You got {0}", gm.PlayerTurn.Resources.N_Cavalry);
                        Console.WriteLine("ARTILLERY| You got {0}", gm.PlayerTurn.Resources.N_Artillery);
                        Console.WriteLine("────────────────────────────────────────────");
                        unit = Console.ReadLine().ToUpper();
                    }
                }

                if (option == "MOVE" && optionalCoordinate != null && addCoordinate.HasValue && (!field.IsOutOfBorders(addCoordinate.Value)))
                {
                    char newLetter = ' ';
                    int  newNumber = 0;
                    try
                    {
                        string[] optionalCoordinateSplit = optionalCoordinate.Split(',');

                        newLetter = Convert.ToChar(optionalCoordinateSplit[0]);
                        newNumber = Int32.Parse(optionalCoordinateSplit[1]);
                    }
                    catch (FormatException e)
                    {
                        Utils.ColorWrite(ConsoleColor.Red, "You need to write letter,number");
                        Console.WriteLine();
                    }

                    Coordinate moveCoordinate = new Coordinate(newLetter, newNumber);

                    if (field.IsOutOfBorders(moveCoordinate))
                    {
                        Console.WriteLine("You can't move a unit to out of the field!");
                    }

                    //TODO : Remove this from where when the update doesn't needs the GameEntity
                    GameEntity ge = null;
                    if (gm.PlayerTurn == gm.Player1)
                    {
                        if (gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value) != null)
                        {
                            if (gm.PlayerTurn.Resources.IsCoordinateAvailable(moveCoordinate) == null && gm.Player2.Resources.IsCoordinateAvailable(moveCoordinate) == null)
                            {
                                ge = gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value);
                                if (ge is Building)
                                {
                                    errorMessage = "You cannot move buildings!";
                                }
                                else if (ge != null)
                                {
                                    Unit u = ge as Unit;

                                    int distance     = ge.Distance(moveCoordinate);
                                    int moveDistance = u.CanMove(distance, n_moves);
                                    if (moveDistance > 0)
                                    {
                                        n_moves -= moveDistance;
                                        gm.PlayerTurn.Resources.MoveEntity(ge, moveCoordinate);
                                        //field.Update();
                                    }
                                    else
                                    {
                                        errorMessage = "You don't have enough move points to do that!";
                                    }
                                }
                            }
                            else
                            {
                                errorMessage = "You can't do that!";
                            }
                        }
                        else
                        {
                            errorMessage = "You cannot move the unknown!";
                        }
                    }
                    else if (gm.PlayerTurn == gm.Player2)
                    {
                        if (gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value) != null)
                        {
                            if (gm.PlayerTurn.Resources.IsCoordinateAvailable(moveCoordinate) == null && gm.Player1.Resources.IsCoordinateAvailable(moveCoordinate) == null)
                            {
                                ge = gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value);
                                if (ge is Building)
                                {
                                    errorMessage = "You cannot move buildings!";
                                }
                                else if (ge != null)
                                {
                                    Unit u = ge as Unit;

                                    int distance     = ge.Distance(moveCoordinate);
                                    int moveDistance = u.CanMove(distance, n_moves);
                                    if (moveDistance > 0)
                                    {
                                        n_moves -= moveDistance;
                                        gm.PlayerTurn.Resources.MoveEntity(ge, moveCoordinate);
                                        //field.Update();
                                    }
                                    else
                                    {
                                        errorMessage = "You don't have enough move points to do that!";
                                    }
                                }
                            }
                            else
                            {
                                errorMessage = "You can't do that!";
                            }
                        }

                        else
                        {
                            errorMessage = "You cannot move the unknown!";
                        }
                    }

                    addCoordinate = null;

                    optionalCoordinate = null;

                    field.Update();

                    if (errorMessage != null)
                    {
                        Console.WriteLine(errorMessage);
                        errorMessage = null;
                    }

                    Console.WriteLine("Are you done? Do you want to finish the turn? (Yes or No)");
                    isNewTurn = Console.ReadLine().ToUpper();

                    if (isNewTurn == "YES")
                    {
                        isNewTurn = null;
                        gm.NewTurn();
                    }
                }
                else if (option == "ATTACK" && optionalCoordinate != null && addCoordinate.HasValue)
                {
                    string[] optionalCoordinateSplit = optionalCoordinate.Split(',');

                    char       newLetter      = Convert.ToChar(optionalCoordinateSplit[0]);
                    int        newNumber      = Int32.Parse(optionalCoordinateSplit[1]);
                    Coordinate moveCoordinate = new Coordinate(newLetter, newNumber);

                    if (gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value) != null)
                    {
                        GameEntity playerEntity = gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value);
                        if (playerEntity is Unit)
                        {
                            Unit playerUnit = playerEntity as Unit;

                            Player enemy = gm.PlayerTurn == gm.Player1 ? gm.Player2 : gm.Player1;

                            if (enemy.Resources.IsCoordinateAvailable(moveCoordinate) != null)
                            {
                                GameEntity enemyEntity = enemy.Resources.IsCoordinateAvailable(moveCoordinate);

                                int distanceToEnemy = playerEntity.Distance(moveCoordinate);
                                if (distanceToEnemy <= playerUnit.AttackRange)
                                {
                                    if (enemyEntity.TakeDamage(playerUnit.AttackValue))
                                    {
                                        gm.PlayerTurn.Resources.Score += enemyEntity.Score;
                                        enemy.Resources.RemoveEntity(enemyEntity);
                                        if (enemyEntity is PlayerBase)
                                        {
                                            gm.SetGameOver();
                                            return;
                                        }

                                        //gm.PlayerTurn.Resources.MoveEntity(playerEntity, moveCoordinate);
                                    }
                                }
                                else
                                {
                                    errorMessage = "That's to far for my range!";
                                }
                            }
                            else if (gm.PlayerTurn.Resources.IsCoordinateAvailable(moveCoordinate) != null)
                            {
                                errorMessage = "You can't attack your self!";
                            }
                        }
                        else
                        {
                            errorMessage = "You can't attack other unit with a building selected!";
                        }
                    }
                    else
                    {
                        errorMessage = "You need to select a unit!";
                    }

                    optionalCoordinate = null;

                    field.Update();

                    if (errorMessage != null)
                    {
                        Console.WriteLine(errorMessage);
                        errorMessage = null;
                    }

                    Console.WriteLine("Are you done? Do you want to finish the turn? (Yes or No)");
                    isNewTurn = Console.ReadLine().ToUpper();

                    if (isNewTurn == "YES")
                    {
                        isNewTurn = null;
                        gm.NewTurn();
                    }
                }
                else if (option == "TRAIN UNITS" && (nArtilleryFactories > 0 || nBarracks > 0 || nStables > 0) && unitToTrain != null)
                {
                    string buildingToWork = null;
                    switch (unitToTrain)
                    {
                    case "INFANTRY":
                        buildingToWork = "barrack";
                        break;

                    case "CAVALRY":
                        buildingToWork = "stable";
                        break;

                    case "ARTILLERY":
                        buildingToWork = "artillery_factory";
                        break;

                    default:
                        errorMessage = "You need to specify the unity!";
                        break;
                    }

                    if (gm.PlayerTurn.Resources.Coins <= 0)
                    {
                        errorMessage = "You don't have enough coins to train any kind of units";
                    }
                    else if (!gm.PlayerTurn.Resources.GetToWork(numberOfUnitsToProduce, buildingToWork))
                    {
                        errorMessage = "You don't have enough coins to train that unit";
                    }

                    isToTrain = false;

                    if (errorMessage != null)
                    {
                        Console.WriteLine(errorMessage);
                        errorMessage = null;
                    }

                    Console.WriteLine("Are you done? Do you want to finish the turn? (Yes or No)");
                    isNewTurn = Console.ReadLine().ToUpper();

                    if (isNewTurn == "YES")
                    {
                        isNewTurn = null;
                        gm.NewTurn();
                    }
                }
                else if (option == "ADD" && optionalCoordinate == null && addCoordinate.HasValue && (!field.IsOutOfBorders(addCoordinate.Value)))
                {
                    GameEntity ge = null;

                    if (unit != null)
                    {
                        switch (unit)
                        {
                        case "INFANTRY":
                            if (gm.PlayerTurn.Resources.N_Infantry > 0)
                            {
                                ge = new Infantry(addCoordinate.Value, gm.PlayerTurn.Color);
                            }
                            break;

                        case "CAVALRY":
                            if (gm.PlayerTurn.Resources.N_Cavalry > 0)
                            {
                                ge = new Cavalry(addCoordinate.Value, gm.PlayerTurn.Color);
                            }
                            break;

                        case "ARTILLERY":
                            if (gm.PlayerTurn.Resources.N_Artillery > 0)
                            {
                                ge = new Artillery(addCoordinate.Value, gm.PlayerTurn.Color);
                            }
                            break;

                        default:
                            errorMessage = "You need to specify the unit!";
                            continue;
                        }

                        if (ge != null)
                        {
                            Building building = null;
                            if (ge is Cavalry)
                            {
                                building = gm.PlayerTurn.Resources.GetRandomBuilding <Stable>();
                            }
                            else if (ge is Artillery)
                            {
                                building = gm.PlayerTurn.Resources.GetRandomBuilding <ArtilleryFactory>();
                            }
                            else if (ge is Infantry)
                            {
                                building = gm.PlayerTurn.Resources.GetRandomBuilding <Barrack>();
                            }
                            if (gm.PlayerTurn.Resources.CanPlaceAroundBuilding(building, gm.GetEnemyPlayer()) != null)
                            {
                                //CanPlaceAroundBuilding needs the enemyPlayer to check if the enemy player has the coordinate free!
                                Coordinate?coordinateFree = gm.PlayerTurn.Resources.CanPlaceAroundBuilding(building, gm.GetEnemyPlayer());
                                if (coordinateFree.HasValue)
                                {
                                    ge.Position = coordinateFree.Value;
                                    gm.PlayerTurn.Resources.AddEntity(ge);
                                }
                                else
                                {
                                    errorMessage = "I can't place the unit around the building!";
                                }
                            }
                        }

                        unit = null;
                    }
                    else if (strBuilding != null)
                    {
                        char firstLetter = addCoordinate.Value.Letter;
                        int  firstNumber = addCoordinate.Value.Number;
                        List <Coordinate> listCoordinates = new List <Coordinate>();

                        Coordinate secondCoordinate = new Coordinate(++firstLetter, firstNumber);
                        Coordinate thirdCoordinate  = new Coordinate(firstLetter, ++firstNumber);
                        Coordinate fourthCoordinate = new Coordinate(--firstLetter, firstNumber);

                        listCoordinates.Add(secondCoordinate);
                        //listCoordinates.Add(thirdCoordinate);
                        //listCoordinates.Add(fourthCoordinate);
                        switch (strBuilding)
                        {
                        case "FARM":
                            ge = new Farm(addCoordinate.Value, listCoordinates, gm.PlayerTurn.Color);
                            break;

                        case "BARRACK":
                            ge = new Barrack(addCoordinate.Value, listCoordinates, gm.PlayerTurn.Color);
                            break;

                        case "STABLE":
                            ge = new Stable(addCoordinate.Value, listCoordinates, gm.PlayerTurn.Color);
                            break;

                        case "ARTILLERY FACTORY":
                            ge = new ArtilleryFactory(addCoordinate.Value, listCoordinates, gm.PlayerTurn.Color);
                            break;

                        default:
                            errorMessage = "You need to specify the building!";
                            continue;
                        }
                        if (gm.PlayerTurn.Resources.IsCoordinateAvailable(addCoordinate.Value) != null ||
                            gm.PlayerTurn.Resources.IsCoordinateAvailable(secondCoordinate) != null)
                        {
                            errorMessage = "There's a unit on that coordinate!";
                        }
                        else if (gm.PlayerTurn == gm.Player1 && gm.Player2.Resources.IsCoordinateAvailable(addCoordinate.Value) != null ||
                                 gm.Player2.Resources.IsCoordinateAvailable(secondCoordinate) != null)
                        {
                            errorMessage = "Enemy collision!";
                        }
                        else if (gm.PlayerTurn == gm.Player2 && gm.Player1.Resources.IsCoordinateAvailable(addCoordinate.Value) != null ||
                                 gm.Player1.Resources.IsCoordinateAvailable(secondCoordinate) != null)
                        {
                            errorMessage = "Enemy collision!";
                        }
                        else
                        {
                            Building b = ge as Building;
                            if (gm.PlayerTurn.Resources.Coins >= b.CostToBuild)
                            {
                                bool hasBuildingClose = gm.PlayerTurn.Resources.HasBuildingClose(b);
                                if (hasBuildingClose)
                                {
                                    gm.PlayerTurn.Resources.AddEntity(ge);
                                }
                                else
                                {
                                    errorMessage = "There's no building around that coordinate!";
                                }
                            }
                            else
                            {
                                errorMessage = "You don't have enough coins to build that building!";
                            }
                        }
                        strBuilding = null;
                    }


                    field.Update();

                    if (errorMessage != null)
                    {
                        Console.WriteLine(errorMessage);
                        errorMessage = null;
                    }

                    Console.WriteLine("Are you done? Do you want to finish the turn? (Yes or No)");
                    isNewTurn = Console.ReadLine().ToUpper();

                    if (isNewTurn == "YES")
                    {
                        isNewTurn = null;
                        gm.NewTurn();
                    }
                }
            } while (option != "EXIT" || !gm.GameFinished);
        }
Пример #24
0
 //Removes a member and destroys them.
 public void Kill(Infantry AI)
 {
     ClearSpot(AI.index);
     Destroy(AI.AIBox);
     Destroy(AI.gameObject);
 }
Пример #25
0
    public void buyCharGold()
    {
        if (_IName.text == "")
        {
            Debug.LogError("buyCharGold: nothing filled in"); return;
        }
        Character newGold = null;

        if (_Career.captionText.text == "Infantry")
        {
            newGold = new Infantry(_Faction.captionText.text);
            FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharInf += 1;
            //Debug.Log ("db check: " + newGold.AssaultTeamsDeployed);
        }
        else if (_Career.captionText.text == "Para")
        {
            newGold = new Para(_Faction.captionText.text);
            FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharPar += 1;
        }
        else if (_Career.captionText.text == "Recon")
        {
            newGold = new Recon(_Faction.captionText.text);
            FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharRec += 1;
        }
        else if (_Career.captionText.text == "Tanker")
        {
            newGold = new Tankman(_Faction.captionText.text);
            FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharTan += 1;
        }
        else if (_Career.captionText.text == "Pilot")
        {
            newGold = new Pilot(_Faction.captionText.text);
            FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharPil += 1;
        }
        else if (_Career.captionText.text == "General")
        {
            newGold      = new General(_Faction.captionText.text);
            newGold.Rank = Character.C_Rank.BrigadierGeneral;
            FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharGen += 1;
        }
        CharacterManager.characterManager.CharCount++;
        newGold.C_DeployID  = CharacterManager.characterManager.CharCount;
        newGold.C_Name      = _IName.text;
        newGold.CharPanel   = CharacterManager.characterManager.CharacterPrefab;
        newGold.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/" + _Faction.captionText.text);
        //newGold.AssaultTeamsDeployed = new List<AssaultTeam> ();

        switch (_Rank.captionText.text)
        {
        case "Private":
            //Debug.Log ("switch: rank private");
            newGold.Rank = Character.C_Rank.Private;
            newGold.setRankIcon(_Faction.captionText.text);

            break;

        case "SecondLieutenant":
            //Debug.Log ("switch: rank SecondLieutenant");
            newGold.Rank = Character.C_Rank.SecondLieutenant;
            newGold.setRankIcon(_Faction.captionText.text);
            newGold.setCommandPoints();

            break;

        case "Major":
            //Debug.Log ("switch: rank Major");
            newGold.Rank = Character.C_Rank.Major;
            newGold.setRankIcon(_Faction.captionText.text);
            newGold.setCommandPoints();

            break;

        case "BrigadierGeneral":
            //Debug.Log ("switch: rank BrigadierGeneral");
            newGold.Rank = Character.C_Rank.BrigadierGeneral;
            newGold.Type = Character.C_Type.General;
            newGold.setRankIcon(_Faction.captionText.text);
            newGold.setCommandPoints();
            break;
        }
        if (_Career.captionText.text == "General")
        {
            newGold.Rank = Character.C_Rank.BrigadierGeneral;
            newGold.setRankIcon(_Faction.captionText.text);
            newGold.setCommandPoints();
        }

        newGold.RankIcon = FactionManager.control.getRankIcon(newGold.Rank.ToString());

        if (newGold.Type == Character.C_Type.InfantryMan && newGold.Rank == Character.C_Rank.Private)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.BuyPrivateInfGold)
            {
                return;
            }
            else
            {
                GameControl.control.Gold -= CostAndPrices.CAP.BuyPrivateInfGold;
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                costsGold.text = CostAndPrices.CAP.BuyPrivateInfGold.ToString();
            }
        }
        else if (newGold.Type == Character.C_Type.InfantryMan && newGold.Rank == Character.C_Rank.SecondLieutenant)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.Buy2ndLutInfGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.Buy2ndLutInfGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.Buy2ndLutInfGold;
            }
        }
        else if (newGold.Type == Character.C_Type.InfantryMan && newGold.Rank == Character.C_Rank.Major)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.BuyMajorInfGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.BuyMajorInfGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.BuyMajorInfGold;
            }

            // Para
        }
        else if (newGold.Type == Character.C_Type.Para && newGold.Rank == Character.C_Rank.Private)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.BuyPrivateParaGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.BuyPrivateParaGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.BuyPrivateParaGold;
            }
        }
        else if (newGold.Type == Character.C_Type.Para && newGold.Rank == Character.C_Rank.SecondLieutenant)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.Buy2ndLutParaGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.Buy2ndLutParaGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.Buy2ndLutParaGold;
            }
        }
        else if (newGold.Type == Character.C_Type.Para && newGold.Rank == Character.C_Rank.Major)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.BuyMajorParaGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.BuyMajorParaGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.BuyMajorParaGold;
            }
            //Recon
        }
        else if (newGold.Type == Character.C_Type.Recon && newGold.Rank == Character.C_Rank.Private)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.BuyPrivateReconGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.BuyPrivateReconGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.BuyPrivateReconGold;
            }
        }
        else if (newGold.Type == Character.C_Type.Recon && newGold.Rank == Character.C_Rank.SecondLieutenant)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.Buy2ndLutReconGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.Buy2ndLutReconGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.Buy2ndLutReconGold;
            }
        }
        else if (newGold.Type == Character.C_Type.Recon && newGold.Rank == Character.C_Rank.Major)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.BuyMajorReconGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.BuyMajorReconGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.BuyMajorReconGold;
            }

            // Tanker
        }
        else if (newGold.Type == Character.C_Type.TankMan && newGold.Rank == Character.C_Rank.Private)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.BuyPrivateTankerGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.BuyPrivateTankerGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.BuyPrivateTankerGold;
            }
        }
        else if (newGold.Type == Character.C_Type.TankMan && newGold.Rank == Character.C_Rank.SecondLieutenant)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.Buy2ndLutTankerGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.Buy2ndLutTankerGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.Buy2ndLutTankerGold;
            }
        }
        else if (newGold.Type == Character.C_Type.TankMan && newGold.Rank == Character.C_Rank.Major)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.BuyMajorTankerGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.BuyMajorTankerGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.BuyMajorTankerGold;
            }

            // Pilot
        }
        else if (newGold.Type == Character.C_Type.Pilot && newGold.Rank == Character.C_Rank.Private)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.BuyPrivatePilotGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.BuyPrivatePilotGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.BuyPrivatePilotGold;
            }
        }
        else if (newGold.Type == Character.C_Type.Pilot && newGold.Rank == Character.C_Rank.SecondLieutenant)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.Buy2ndLutPilotGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.Buy2ndLutPilotGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.Buy2ndLutPilotGold;
            }
        }
        else if (newGold.Type == Character.C_Type.Pilot && newGold.Rank == Character.C_Rank.Major)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.BuyMajorPilotGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.BuyMajorPilotGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.BuyMajorPilotGold;
            }

            // General
        }
        else if (newGold.Type == Character.C_Type.General && newGold.Rank == Character.C_Rank.BrigadierGeneral)
        {
            if (GameControl.control.Gold < CostAndPrices.CAP.BuyGeneralGold)
            {
                return;
            }
            else
            {
                costsGold.text = CostAndPrices.CAP.BuyGeneralGold.ToString();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newGold);
                GameControl.control.Gold -= CostAndPrices.CAP.BuyGeneralGold;
            }
        }



        //FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedChar += 1;
        //Debug.LogError (FactionManager.control.Factions [_Faction.captionText.text].Characters.Count);
    }
Пример #26
0
    public void buyCharCredit()
    {
        Debug.LogError("buyc start");
        if (_IName.text == "")
        {
            Debug.LogError("buyCharCredit: nothing filled in"); return;
        }

        Character newCredit = null;

        if (_Career.captionText.text == "Infantry")
        {
            newCredit = new Infantry(_Faction.captionText.text);
            CharacterManager.characterManager.CharCount++;
            newCredit.C_DeployID = CharacterManager.characterManager.CharCount;

            Debug.LogError("set inf");
        }
        else if (_Career.captionText.text == "Para")
        {
            newCredit = new Para(_Faction.captionText.text);

            Debug.LogError("set para");
        }
        else if (_Career.captionText.text == "Recon")
        {
            newCredit = new Recon(_Faction.captionText.text);
            CharacterManager.characterManager.CharCount++;
            newCredit.C_DeployID = CharacterManager.characterManager.CharCount;

            Debug.LogError("set recon");
        }
        else if (_Career.captionText.text == "Tanker")
        {
            newCredit = new Tankman(_Faction.captionText.text);
            CharacterManager.characterManager.CharCount++;
            newCredit.C_DeployID = CharacterManager.characterManager.CharCount;

            Debug.LogError("set tanker");
        }
        else if (_Career.captionText.text == "Pilot")
        {
            newCredit = new Pilot(_Faction.captionText.text);
            CharacterManager.characterManager.CharCount++;
            newCredit.C_DeployID = CharacterManager.characterManager.CharCount;

            Debug.LogError("set pilot");
        }
        else if (_Career.captionText.text == "General")
        {
            newCredit = new General(_Faction.captionText.text);
            CharacterManager.characterManager.CharCount++;
            newCredit.C_DeployID = CharacterManager.characterManager.CharCount;
            newCredit.Rank       = Character.C_Rank.BrigadierGeneral;

            Debug.LogError("set general");
        }

        newCredit.C_Name      = _IName.text;
        newCredit.CharPanel   = CharacterManager.characterManager.CharacterPrefab;
        newCredit.FactionFlag = Resources.Load <Texture> ("Images/FactionFlags/" + _Faction.captionText.text);
        //newCredit.AssaultTeamsDeployed = new List<AssaultTeam> ();
        Debug.LogError("set rank");
        switch (_Rank.captionText.text)
        {
        case "Private":
            //Debug.Log ("switch: rank private");
            newCredit.Rank = Character.C_Rank.Private;
            newCredit.setRankIcon(_Faction.captionText.text);

            break;

        case "SecondLieutenant":
            //Debug.Log ("switch: rank SecondLieutenant");
            newCredit.Rank = Character.C_Rank.SecondLieutenant;
            newCredit.setRankIcon(_Faction.captionText.text);
            newCredit.setCommandPoints();

            break;

        case "Major":
            //Debug.Log ("switch: rank Major");
            newCredit.Rank = Character.C_Rank.Major;
            newCredit.setRankIcon(_Faction.captionText.text);
            newCredit.setCommandPoints();

            break;

        case "BrigadierGeneral":
            //Debug.Log ("switch: rank BrigadierGeneral");
            newCredit.Rank = Character.C_Rank.BrigadierGeneral;
            newCredit.Type = Character.C_Type.General;
            newCredit.setRankIcon(_Faction.captionText.text);
            newCredit.setCommandPoints();
            break;
        }
        if (_Career.captionText.text == "General")
        {
            newCredit.Rank = Character.C_Rank.BrigadierGeneral;
            newCredit.setRankIcon(_Faction.captionText.text);
        }

        newCredit.RankIcon = FactionManager.control.getRankIcon(newCredit.Rank.ToString());
        Debug.LogError("set price");
        if (newCredit.Type == Character.C_Type.InfantryMan && newCredit.Rank == Character.C_Rank.Private)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.BuyPrivateInfCred)
            {
                return;
            }
            else
            {
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.BuyPrivateInfCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharInf += 1;
            }
        }
        else if (newCredit.Type == Character.C_Type.InfantryMan && newCredit.Rank == Character.C_Rank.SecondLieutenant)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.Buy2ndLutInfCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.Buy2ndLutInfCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.Buy2ndLutInfCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharInf += 1;
            }
        }
        else if (newCredit.Type == Character.C_Type.InfantryMan && newCredit.Rank == Character.C_Rank.Major)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.BuyMajorInfCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.BuyMajorInfCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.BuyMajorInfCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharInf += 1;
            }

            // Para
        }
        else if (newCredit.Type == Character.C_Type.Para && newCredit.Rank == Character.C_Rank.Private)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.BuyPrivateParaCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.BuyPrivateParaCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.BuyPrivateParaCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharPar += 1;
            }
        }
        else if (newCredit.Type == Character.C_Type.Para && newCredit.Rank == Character.C_Rank.SecondLieutenant)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.Buy2ndLutParaCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.Buy2ndLutParaCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.Buy2ndLutParaCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharPar += 1;
            }
        }
        else if (newCredit.Type == Character.C_Type.Para && newCredit.Rank == Character.C_Rank.Major)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.BuyMajorParaCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.BuyMajorParaCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.BuyMajorParaCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharPar += 1;
            }
            //Recon
        }
        else if (newCredit.Type == Character.C_Type.Recon && newCredit.Rank == Character.C_Rank.Private)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.BuyPrivateReconCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.BuyPrivateReconCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.BuyPrivateReconCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharRec += 1;
            }
        }
        else if (newCredit.Type == Character.C_Type.Recon && newCredit.Rank == Character.C_Rank.SecondLieutenant)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.Buy2ndLutReconCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.Buy2ndLutReconCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.Buy2ndLutReconCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharRec += 1;
            }
        }
        else if (newCredit.Type == Character.C_Type.Recon && newCredit.Rank == Character.C_Rank.Major)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.BuyMajorReconCred)
            {
                //_Faction.captionText.text = "";
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.BuyMajorReconCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.BuyMajorReconCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharRec += 1;
            }

            // Tanker
        }
        else if (newCredit.Type == Character.C_Type.TankMan && newCredit.Rank == Character.C_Rank.Private)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.BuyPrivateTankerCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.BuyPrivateTankerCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.BuyPrivateTankerCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharTan += 1;
            }
        }
        else if (newCredit.Type == Character.C_Type.TankMan && newCredit.Rank == Character.C_Rank.SecondLieutenant)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.Buy2ndLutTankerCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.Buy2ndLutTankerCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.Buy2ndLutTankerCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharTan += 1;
            }
        }
        else if (newCredit.Type == Character.C_Type.TankMan && newCredit.Rank == Character.C_Rank.Major)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.BuyMajorTankerCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.BuyMajorTankerCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.BuyMajorTankerCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharTan += 1;
            }

            // Pilot
        }
        else if (newCredit.Type == Character.C_Type.Pilot && newCredit.Rank == Character.C_Rank.Private)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.BuyPrivatePilotCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.BuyPrivatePilotCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.BuyPrivatePilotCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharPil += 1;
            }
        }
        else if (newCredit.Type == Character.C_Type.Pilot && newCredit.Rank == Character.C_Rank.SecondLieutenant)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.Buy2ndLutPilotCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.Buy2ndLutPilotCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.Buy2ndLutPilotCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharPil += 1;
            }
        }
        else if (newCredit.Type == Character.C_Type.Pilot && newCredit.Rank == Character.C_Rank.Major)
        {
            if (GameControl.control.Credits < CostAndPrices.CAP.BuyMajorPilotCred)
            {
                return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.BuyMajorPilotCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.BuyMajorPilotCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharPil += 1;
            }

            // General
        }
        else if (newCredit.Type == Character.C_Type.General && newCredit.Rank == Character.C_Rank.BrigadierGeneral)
        {
            Debug.LogError("general, brigadier");
            if (GameControl.control.Credits < CostAndPrices.CAP.BuyGeneralCred)
            {
                //Debug.LogError ("general, brigadier = not ok to buy");
                //return;
            }
            else
            {
                //costsCred.text = CostAndPrices.CAP.BuyGeneralCred.ToString ();
                FactionManager.control.Factions [_Faction.captionText.text].Characters.Add(newCredit);
                GameControl.control.Credits -= CostAndPrices.CAP.BuyGeneralCred;
                FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedCharGen += 1;
                //Debug.LogError ("general, brigadier = ok to buy");
            }
        }
        //FactionManager.control.Factions [_Faction.captionText.text].TotalOwnedChar += 1;
        //Debug.LogError ("buyc end id = " + newCredit.C_ID.ToString());
        //Debug.LogError ("Character section: id check = " + newCredit.C_ID.ToString());
    }
Пример #27
0
 internal static void InvokeInfantryDied(Infantry infantry)
 {
     InfantryDied?.Invoke(null, new EnemyDeathEventArgs(infantry.gameObject));
 }