Exemple #1
0
        public static GameEntity CreateEnemy(Contexts contexts, Vector2 pos)
        {
            var enemy = contexts.game.CreateEntity();

            enemy.AddPrefab("Prefabs/Enemies/spider");
            enemy.AddPosition(pos);
            enemy.isEnemy           = true;
            enemy.isRemovedWhenDead = true;

            MovementHelpers.AddMovementComponents(enemy, 2f, .25f, .5f, .8f, 1f);
            SightHelpers.AddSightComponents(enemy, 50);
            CombatHelpers.AddCombatComponents(enemy, 5f, 3f, .5f);

            var agent = new EntityGoapAgent(contexts, enemy);

            agent.AddAction(new CloseRangeAttackAction());
            agent.AddAction(new GetCloseToTargetAction());
            agent.AddAction(new TargetMinersAction());
            agent.AddGoal(new DestroyMineGoal());
            enemy.AddGoapAgent(agent);


            var animDirector = new AnimationDirector(enemy);

            enemy.AddAnimationDirector(animDirector);

            var combatDirector = new CombatDirector(enemy);

            combatDirector.AddAttack(new MeleeAttack(enemy, "spider_walk", new [] { 24 }));
            enemy.AddCombatDirector(combatDirector);

            return(enemy);
        }
Exemple #2
0
        public static GameEntity CreateMiner(Contexts contexts, Vector2 pos)
        {
            var e = contexts.game.CreateEntity();

            e.AddPrefab("Prefabs/Miners/miner_grunt");
            e.AddPosition(pos);
            MovementHelpers.AddMovementComponents(e, 3f, .25f, .5f, .5f, .8f);
            SightHelpers.AddSightComponents(e, 10f);
            e.isMiner = true;

            var health   = StatCalculator.Calculate(BaseHealth, 1);
            var damage   = StatCalculator.Calculate(BaseMiningDamage, 1);
            var cooldown = StatCalculator.Calculate(BaseMiningSpeed, 1);

            CombatHelpers.AddCombatComponents(e, health, damage, cooldown);

            var animDirector = new AnimationDirector(e);

            e.AddAnimationDirector(animDirector);
            e.isKillable = true;


            var agent = new EntityGoapAgent(contexts, e);

            agent.AddAction(new CloseRangeAttackAction());
            agent.AddAction(new GetCloseToTargetAction());
            agent.AddAction(new TargetOreBranchAction());
            agent.AddAction(new MineAction());
            agent.AddGoal(new AcquireOreGoal());
            e.AddGoapAgent(agent);


            var combatDirector = new CombatDirector(e);

            combatDirector.AddAttack(new MeleeAttack(e, "miner_grunt_mine_regular", new[] { 24 }));
            e.AddCombatDirector(combatDirector);

            e.AddBag(new List <int>());

            return(e);
        }
Exemple #3
0
        public static GameEntity CreateTurret(Contexts contexts, Vector2 pos)
        {
            var turret = contexts.game.CreateEntity();

            turret.AddPosition(pos);
            turret.AddPrefab("Prefabs/Towers/tower_rifle");


            var muzzle = contexts.game.CreateEntity();

            muzzle.AddPrefab("Prefabs/Towers/tower_rifle_gun");
            muzzle.isLookingAtTarget = true;

            muzzle.AddParent(turret.id.value);
            muzzle.AddPositionOffset(new Vector2(-0.056f, -0.118f));

            CombatHelpers.AddCombatComponents(muzzle, 5f, .5f, .1f);
            SightHelpers.AddSightComponents(muzzle, 10f);

            var turretAgent = new EntityGoapAgent(contexts, muzzle);

            turretAgent.AddGoal(new DefendMineGoal());
            turretAgent.AddAction(new TargetMineIntruderAction());
            turretAgent.AddAction(new RangeAttackAction());
            muzzle.AddGoapAgent(turretAgent);


            var turretAnim = new AnimationDirector(muzzle);

            muzzle.AddAnimationDirector(turretAnim);

            var turretCombat = new CombatDirector(muzzle);

            turretCombat.AddAttack(new MeleeAttack(muzzle, "tower_rifle_gun_fire", new[] { 3 }));
            muzzle.AddCombatDirector(turretCombat);
            return(turret);
        }