Пример #1
0
        public RedGuard(Thing chaseTarget)
            : base("pixie")
        {
            IsCollisionFree    = false;
            DrawInfo.DrawColor = new Color(255, 10, 4);
            Health             = 13f;

            ComplexBehavior = new SubsumptionBehavior();
            Add(ComplexBehavior);

            Combat = new CombatBehavior(typeof(Knight));
            ComplexBehavior.Add(Combat);

            // chase knights that are very close
            ChasingComp            = new ChaseBehavior(typeof(Knight), true);
            ChasingComp.MoveSpeed  = RandomMath.RandomBetween(0.43f, 0.65f);
            ChasingComp.ChaseRange = 2f; // RandomMath.RandomBetween(12f, 40f);
            ComplexBehavior.Add(ChasingComp);

            // chase hero
            Chasing            = new ChaseBehavior(chaseTarget);
            Chasing.MoveSpeed  = RandomMath.RandomBetween(0.47f, 0.75f);
            Chasing.ChaseRange = 14f; // RandomMath.RandomBetween(12f, 40f);
            ComplexBehavior.Add(Chasing);

            Turning           = new AlwaysTurnRightBehavior(); // patrolling
            Turning.MoveSpeed = Chasing.MoveSpeed;             //RandomMath.RandomBetween(0.57f, 1.05f);
            Turning.MoveSpeed = 0.7f;
            ComplexBehavior.Add(Turning);

            Wandering           = new RandomWanderBehavior(2.7f, 11.3f);
            Wandering.MoveSpeed = 0.7f;
            ComplexBehavior.Add(Wandering);
        }
Пример #2
0
        /// <summary>
        /// Factory method to create new Red Guard
        /// </summary>
        /// <returns></returns>
        public static Entity Create()
        {
            ChaseBehavior ChasingHero;
            //ChaseBehavior ChasingCompanions;
            AlwaysTurnRightBehavior Turning;
            RandomWanderBehavior    Wandering;
            AttackEnemyBehavior     Attacking;

            var e  = GameFactory.CreateThing(ThingType.RED_GUARD, true);
            var ai = new BTAIComp();

            e.AddComponent(ai);
            var sub = new PrioritySelector();

            ai.rootNode = sub;

            var tc = e.GetComponent <ThingComp>();

            tc.IsCollisionFree = false;
            tc.Color           = new Color(255, 10, 4);
            tc.Faction         = Faction.EVIL;

            var rwc = new RandomWanderComp();

            e.AddComponent(rwc);
            rwc.MinDirectionChangeTime = 2.7;
            rwc.MaxDirectionChangeTime = 11.3;

            // attack hero or companions
            Attacking = new AttackEnemyBehavior(attackString);

            // chase companions that are very close

            /*
             * ChasingCompanions = new ChaseBehavior(typeof(Companion));
             * ChasingCompanions.DeltaTimeBetweenMoves = RandomMath.RandomBetween(0.43f, 0.65f);
             * ChasingCompanions.ChaseRange = 1.5f; // RandomMath.RandomBetween(12f, 40f);
             * sub.AddChild(ChasingCompanions);
             */

            // chase hero
            ChasingHero = new ChaseBehavior(Level.Current.Hero);
            ChasingHero.DeltaTimeBetweenMoves = RandomMath.RandomBetween(0.47f, 0.75f);
            ChasingHero.ChaseRange            = 15f; // RandomMath.RandomBetween(12f, 40f);
            sub.AddChild(ChasingHero);

            Turning = new AlwaysTurnRightBehavior();                           // patrolling
            Turning.DeltaTimeBetweenMoves = ChasingHero.DeltaTimeBetweenMoves; //RandomMath.RandomBetween(0.57f, 1.05f);
            Turning.DeltaTimeBetweenMoves = 0.7f;
            sub.AddChild(Turning);

            Wandering = new RandomWanderBehavior();
            Wandering.DeltaTimeBetweenMoves = 0.7f;
            sub.AddChild(Wandering);

            e.Refresh();
            return(e);
        }
        public BadPixel(Thing chaseTarget)
            : base("shape2x2")
        {
            IsCollisionFree    = false;
            DrawInfo.DrawColor = new Color(255, 10, 4);

            SubsumptionBehavior sub = new SubsumptionBehavior();

            Add(sub);

            Chasing            = new ChaseBehavior(chaseTarget);
            Chasing.MoveSpeed  = RandomMath.RandomBetween(0.47f, 0.75f);
            Chasing.ChaseRange = 6f; // RandomMath.RandomBetween(12f, 40f);
            sub.Add(Chasing);

            Turning           = new AlwaysTurnRightBehavior();
            Turning.MoveSpeed = Chasing.MoveSpeed; //RandomMath.RandomBetween(0.57f, 1.05f);
            Turning.MoveSpeed = 0.7f;
            sub.Add(Turning);

            Wandering           = new RandomWanderBehavior(2.7f, 11.3f);
            Wandering.MoveSpeed = 0.7f;
            sub.Add(Wandering);
        }