public GameEntityBatch(string entName, int entCount, int spawnDelay, ArtificialIntelligence sourceAI)
 {
     this.GameEntityName = entName;
     this.GameEntityCount = entCount;
     this.spawnDelay = spawnDelay;
     this.templateAI = sourceAI;
 }
        public ArtificialIntelligence Clone()
        {
            //be sure to expand this to handle other properties as AI grows...

            ArtificialIntelligence newAI = new ArtificialIntelligence();
            newAI.SetMovementPath(this.GetMovementPath());
            newAI.DestinationArrival = this.DestinationArrival;

            return newAI;
        }
        private List<Weapon> weapons; // = new List<Weapon>();

        #endregion Fields

        #region Constructors

        public LivingGameEntity(string entName, string entId = "")
            : base(entName, entId)
        {
            //give it a / the default AI...
            this.ai = new ArtificialIntelligence();
            this.weapons = new List<Weapon>();
            this.ViewRadius = 5;

            //LivingGameEntity.cachedEntities.Add(this);
            CacheLivingEntity(this);
        }
        public void AddGameEntityBatch(string entityName, int GameEntityCount, int spawnDelay, ArtificialIntelligence sourceAI)
        {
            GameEntityBatch newBatch = new GameEntityBatch(entityName, GameEntityCount, spawnDelay, sourceAI);
            this.spawnBatches.Add(newBatch);

            this.Activate();
        }
 public void SetAI(ArtificialIntelligence newAi)
 {
     if (newAi != null)
     {
         this.ai = Helpah.Clone(newAi).As<ArtificialIntelligence>();
         this.ai.SetBody(this);
     }
     else
     {
         this.ai = null;
     }
 }
Exemple #6
0
        private void customCreatureThoughtPattern(ArtificialIntelligence creatureAI)
        {
            Point creaturePos = creatureAI.GetBody().GetPosition();
            Color creatureColor = Color.Black;
            List<LightSource> nearLights = LightSource.GetLocalLightSources(creaturePos.x, creaturePos.y);

            //if there's a light of the opposite color close to us, run from it, and don't think of anything else
            foreach (LightSource light in nearLights)
            {
                if (light is Lightstone)
                {
                    continue;
                }

                if (light.GetColor().IsOpposite(creatureColor))
                {
                    //run away!
                    creatureAI.GetBody().SetDirection(GetOppositeDirection(creaturePos, light.GetPosition()));
                }
            }

            //if there's an active lightstone nearby, check if we're in range to be able to attack it

            //if we are in range, attack it
            //if we're not in range, move closer to it
        }
Exemple #7
0
        public void createShadowCreature(int x, int y)
        {
            LivingGameEntity shadowCreature = new LivingGameEntity("ShadowCreature");
            shadowCreature.AddCustomStyling("shadowCreature");
            shadowCreature.SetParentStage(Stage.CurrentStage);
            Stage.CurrentStage.AddLivingGameEntity(shadowCreature);
            shadowCreature.SetPosition(x, y);

            ArtificialIntelligence creatureAI = new ArtificialIntelligence();
            creatureAI.SetMovementThoughtPattern(customCreatureThoughtPattern);
            shadowCreature.SetAI(creatureAI);
        }
        private void exitReached(ArtificialIntelligence ai)
        {
            ai.GetBody().Destroy();

            playerHealth -= 1;
            GuiLayer.GetLayerByName("HUD").GetGUIElement(1).As<LabelValue>().SetValue(playerHealth.ToString());

            if (playerHealth == 0)
            {
                levelDefeat();
            }
            // If there are no more enemies...
            else if (this.levelEntryPoint.Active == false && enemyFaction.EntityCount == 0)
            {
                levelVictory();
            }
        }