Пример #1
0
        /// <summary>
        /// Constructor with one param: side
        /// side = 0: BLACK
        /// side = 1: RED
        /// </summary>
        /// <param name="side"></param>
        public Player(int side)
        {
            AdvisorPieces[0]  = new Advisor();
            AdvisorPieces[1]  = new Advisor();
            ElephantPieces[0] = new Elephant();
            ElephantPieces[1] = new Elephant();
            ChariotPieces[0]  = new Chariot();
            ChariotPieces[1]  = new Chariot();
            CannonPieces[0]   = new Cannon();
            CannonPieces[1]   = new Cannon();
            HorsePieces[0]    = new Horse();
            HorsePieces[1]    = new Horse();
            SoldierPieces[0]  = new Soldier();
            SoldierPieces[1]  = new Soldier();
            SoldierPieces[2]  = new Soldier();
            SoldierPieces[3]  = new Soldier();
            SoldierPieces[4]  = new Soldier();

            if (side == 0) // BLACK
            {
                //Side = 0;
                KingPiece.Init(0, "KING", 0, 1, true, 0, 4);
                AdvisorPieces[0].Init(0, "ADVISOR", 0, 1, true, 0, 3);
                AdvisorPieces[1].Init(0, "ADVISOR", 1, 1, true, 0, 5);
                ElephantPieces[0].Init(0, "ELEPHANT", 0, 1, true, 0, 2);
                ElephantPieces[1].Init(0, "ELEPHANT", 1, 1, true, 0, 6);
                HorsePieces[0].Init(0, "HORSE", 0, 1, true, 0, 1);
                HorsePieces[1].Init(0, "HORSE", 1, 1, true, 0, 7);
                ChariotPieces[0].Init(0, "CHARIOT", 0, 1, true, 0, 0);
                ChariotPieces[1].Init(0, "CHARIOT", 1, 1, true, 0, 8);
                CannonPieces[0].Init(0, "CANNON", 0, 1, true, 2, 1);
                CannonPieces[1].Init(0, "CANNON", 1, 1, true, 2, 7);
                SoldierPieces[0].Init(0, "SOLDIER", 0, 1, true, 3, 0);
                SoldierPieces[1].Init(0, "SOLDIER", 1, 1, true, 3, 2);
                SoldierPieces[2].Init(0, "SOLDIER", 2, 1, true, 3, 4);
                SoldierPieces[3].Init(0, "SOLDIER", 3, 1, true, 3, 6);
                SoldierPieces[4].Init(0, "SOLDIER", 4, 1, true, 3, 8);
            }
            else    // RED
            {
                //Side = 1;
                KingPiece.Init(1, "KING", 0, 1, false, 9, 4);
                AdvisorPieces[0].Init(1, "ADVISOR", 0, 1, false, 9, 3);
                AdvisorPieces[1].Init(1, "ADVISOR", 1, 1, false, 9, 5);
                ElephantPieces[0].Init(1, "ELEPHANT", 0, 1, false, 9, 2);
                ElephantPieces[1].Init(1, "ELEPHANT", 1, 1, false, 9, 6);
                HorsePieces[0].Init(1, "HORSE", 0, 1, false, 9, 1);
                HorsePieces[1].Init(1, "HORSE", 1, 1, false, 9, 7);
                ChariotPieces[0].Init(1, "CHARIOT", 0, 1, false, 9, 0);
                ChariotPieces[1].Init(1, "CHARIOT", 1, 1, false, 9, 8);
                CannonPieces[0].Init(1, "CANNON", 0, 1, false, 7, 1);
                CannonPieces[1].Init(1, "CANNON", 1, 1, false, 7, 7);
                SoldierPieces[0].Init(1, "SOLDIER", 0, 1, false, 6, 0);
                SoldierPieces[1].Init(1, "SOLDIER", 1, 1, false, 6, 2);
                SoldierPieces[2].Init(1, "SOLDIER", 2, 1, false, 6, 4);
                SoldierPieces[3].Init(1, "SOLDIER", 3, 1, false, 6, 6);
                SoldierPieces[4].Init(1, "SOLDIER", 4, 1, false, 6, 8);
            }
        }
    private void ThrowingDynamite()
    {
        TWAudioController.PlaySFX("SFX_PROJECTILE", "dynamite_throw");
        Chariot boss         = (BossBehaviour.Instance as Chariot);
        Vector2 controlPoint = ExtendMath.GetPerpendicular(transform.position, boss.GetActiveGerbong(), 7f, ExtendMath.PerpendicularType.ALWAYS_UP);

        ExtendMath.BezierCurve(ref throwingPosition, transform.position, boss.GetActiveGerbong(), controlPoint, 10);
        CalculateDistanceThrowTime();
        throwTime = AdjustTimeByDistance();
        MoveToThrow(1);
    }
Пример #3
0
        internal static void CityProduction(City city)
        {
            if (city == null || city.Size == 0 || city.Tile == null)
            {
                return;
            }

            Player      player     = Game.GetPlayer(city.Owner);
            IProduction production = null;

            // Create 2 defensive units per city
            if (player.HasAdvance <LaborUnion>())
            {
                if (city.Tile.Units.Count(x => x is MechInf) < 2)
                {
                    production = new MechInf();
                }
            }
            else if (player.HasAdvance <Conscription>())
            {
                if (city.Tile.Units.Count(x => x is Riflemen) < 2)
                {
                    production = new Riflemen();
                }
            }
            else if (player.HasAdvance <Gunpowder>())
            {
                if (city.Tile.Units.Count(x => x is Musketeers) < 2)
                {
                    production = new Musketeers();
                }
            }
            else if (player.HasAdvance <BronzeWorking>())
            {
                if (city.Tile.Units.Count(x => x is Phalanx) < 2)
                {
                    production = new Phalanx();
                }
            }
            else
            {
                if (city.Tile.Units.Count(x => x is Militia) < 2)
                {
                    production = new Militia();
                }
            }

            // Create city improvements
            if (production == null)
            {
                if (!city.HasBuilding <Barracks>())
                {
                    production = new Barracks();
                }
                else if (player.HasAdvance <Pottery>() && !city.HasBuilding <Granary>())
                {
                    production = new Granary();
                }
                else if (player.HasAdvance <CeremonialBurial>() && !city.HasBuilding <Temple>())
                {
                    production = new Temple();
                }
                else if (player.HasAdvance <Masonry>() && !city.HasBuilding <CityWalls>())
                {
                    production = new CityWalls();
                }
            }

            // Create Settlers
            if (production == null)
            {
                if (city.Size > 3 && !city.Units.Any(x => x is Settlers) && player.Cities.Length < 10)
                {
                    production = new Settlers();
                }
            }

            // Create some other unit
            if (production == null)
            {
                if (city.Units.Length < 4)
                {
                    if (player.Government is Republic || player.Government is Democratic)
                    {
                        if (player.HasAdvance <Writing>())
                        {
                            production = new Diplomat();
                        }
                    }
                    else
                    {
                        if (player.HasAdvance <Automobile>())
                        {
                            production = new Armor();
                        }
                        else if (player.HasAdvance <Metallurgy>())
                        {
                            production = new Cannon();
                        }
                        else if (player.HasAdvance <Chivalry>())
                        {
                            production = new Knights();
                        }
                        else if (player.HasAdvance <TheWheel>())
                        {
                            production = new Chariot();
                        }
                        else if (player.HasAdvance <HorsebackRiding>())
                        {
                            production = new Cavalry();
                        }
                        else if (player.HasAdvance <IronWorking>())
                        {
                            production = new Legion();
                        }
                    }
                }
                else
                {
                    if (player.HasAdvance <Trade>())
                    {
                        production = new Caravan();
                    }
                }
            }

            // Set random production
            if (production == null)
            {
                IProduction[] items = city.AvailableProduction.ToArray();
                production = items[Common.Random.Next(items.Length)];
            }

            city.SetProduction(production);
        }
Пример #4
0
        private static IUnit CreateUnit(UnitType type, int x, int y)
        {
            IUnit unit;

            switch (type)
            {
            case UnitType.Settlers: unit = new Settlers(); break;

            case UnitType.Militia: unit = new Militia(); break;

            case UnitType.Phalanx: unit = new Phalanx(); break;

            case UnitType.Legion: unit = new Legion(); break;

            case UnitType.Musketeers: unit = new Musketeers(); break;

            case UnitType.Riflemen: unit = new Riflemen(); break;

            case UnitType.Cavalry: unit = new Cavalry(); break;

            case UnitType.Knights: unit = new Knights(); break;

            case UnitType.Catapult: unit = new Catapult(); break;

            case UnitType.Cannon: unit = new Cannon(); break;

            case UnitType.Chariot: unit = new Chariot(); break;

            case UnitType.Armor: unit = new Armor(); break;

            case UnitType.MechInf: unit = new MechInf(); break;

            case UnitType.Artillery: unit = new Artillery(); break;

            case UnitType.Fighter: unit = new Fighter(); break;

            case UnitType.Bomber: unit = new Bomber(); break;

            case UnitType.Trireme: unit = new Trireme(); break;

            case UnitType.Sail: unit = new Sail(); break;

            case UnitType.Frigate: unit = new Frigate(); break;

            case UnitType.Ironclad: unit = new Ironclad(); break;

            case UnitType.Cruiser: unit = new Cruiser(); break;

            case UnitType.Battleship: unit = new Battleship(); break;

            case UnitType.Submarine: unit = new Submarine(); break;

            case UnitType.Carrier: unit = new Carrier(); break;

            case UnitType.Transport: unit = new Transport(); break;

            case UnitType.Nuclear: unit = new Nuclear(); break;

            case UnitType.Diplomat: unit = new Diplomat(); break;

            case UnitType.Caravan: unit = new Caravan(); break;

            default: return(null);
            }
            unit.X         = x;
            unit.Y         = y;
            unit.MovesLeft = unit.Move;
            return(unit);
        }
        public bool ChariotAjouterProduit(string idConsommateur, Int32 idProduit)
        {
            try
            {
                logger.Info("Requête, Liste des Produits du Consommateur");
                var resultat = (from p in context.Chariots
                                where p.IdConsommateur == new Guid(idConsommateur) && p.IdProduit == idProduit
                                select p).SingleOrDefault();

                if (resultat != null)
                {
                    resultat.Quantite          += 1;
                    resultat.ValeurUnitaire     = resultat.Produit.Valeur;
                    resultat.ValeurTotalArticle = resultat.Produit.Valeur * resultat.Quantite;

                    logger.Info("SaveChagens(), Consommateur a changé la quantité des produits");
                    context.SaveChanges();

                    return(true);
                }
                else
                {
                    logger.Info("Requetê, Verifiér si il y a de Produit avant de Ajouter au Chariot/Panner, SessionConsommateur: " + idConsommateur);
                    var restultatProduit = (from p in context.Produits
                                            where p.IdProduit == idProduit
                                            select p).SingleOrDefault();

                    if (restultatProduit != null)
                    {
                        Chariot chariot = new Chariot();
                        chariot.IdConsommateur     = new Guid(idConsommateur);
                        chariot.IdProduit          = restultatProduit.IdProduit;
                        chariot.ValeurUnitaire     = restultatProduit.Valeur;
                        chariot.ValeurTotalArticle = restultatProduit.Valeur * 1;
                        chariot.Quantite           = 1;
                        chariot.Actif = true;

                        context.Chariots.Add(chariot);
                        context.SaveChanges();
                        logger.Info("SaveChagens(), Consommateur a ajouté le Produit, Session: " + idConsommateur);

                        return(true);
                    }
                    else
                    {
                        logger.Info("Ooopps, Pas de Produit pour le Consommateur ajouter, Session: " + idConsommateur);
                        return(false);
                    }
                }
            }
            catch (IOException iOEx)
            {
                logger.Error("IOException ", iOEx);
                throw iOEx;
            }
            catch (SqlException sqlEx)
            {
                logger.Fatal("SqlException Base de Donnée", sqlEx);
                throw sqlEx;
            }
            catch (Exception ex)
            {
                logger.Error("Exception Générique", ex);
                throw ex;
            }
        }