示例#1
0
        public override void OnPoolInstantiation()
        {
            // Stats
            MoveSpeed = 100.0f;
            DrawColor = Color.White;

            Animator = new Animator();

            EnemyAnimations = EnemyDirector.Instance.BaldAnimations;
            // Position = new Vector2(0);

            stateMachine = new NPCStateMachine(this);

            // Create the states
            IdleState    idle    = new IdleState("idle");
            FleeState    flee    = new FleeState("flee");
            ChaseState   chase   = new ChaseState("chase");
            PowerupState powerup = new PowerupState("powerup", 5.0f);
            ChargeState  charge  = new ChargeState("charge", 10.0f);

            // Transitions
            // From Ideal


            // From Chase
            chase.AddTransition(new Transition(powerup, () => (EnemyDirector.Instance.SqrDistanceToHeroFrom(Position)) <= Math.Pow(distanceToBeginPowerup, 2)));

            // From Powerup
            powerup.AddTransition(new Transition(charge, () => powerup.Done));

            // From Charge
            charge.AddTransition(new Transition(chase, () => charge.Done));

            // Dead Player - All states back to idle
            // ?


            // Add the created states to the FSM
            // stateMachine.AddState(idle);
            // stateMachine.AddState(flee);
            stateMachine.AddState(chase);
            stateMachine.AddState(powerup);
            stateMachine.AddState(charge);

            // Collider Related
            colliderSize = new Vector2Int(2, 2);
            BoundingRect = new Rectangle((int)Position.X, (int)Position.Y, colliderSize.X, colliderSize.Y);

            base.OnPoolInstantiation();
        }
示例#2
0
        public override void OnPoolInstantiation()
        {
            // Stats
            MoveSpeed = 100.0f;
            DrawColor = Color.White;

            Animator = new Animator();

            EnemyAnimations = EnemyDirector.Instance.DarkAnimations;
            // Position = new Vector2(0);

            stateMachine = new NPCStateMachine(this);

            // Create the states
            IdleState  idle  = new IdleState("idle");
            ChaseState chase = new ChaseState("chase");
            ShootState shoot = new ShootState("shoot", 200, 2, true, EnemyDirector.Instance.EnemyBulletTexture);

            // Transitions
            idle.AddTransition(new Transition(chase, () => (Math.Pow(distanceToBeginChase, 2) >= EnemyDirector.Instance.SqrDistanceToHeroFrom(Position))));
            chase.AddTransition(new Transition(shoot, () => (Math.Pow(distanceToBeginShoot, 2) >= EnemyDirector.Instance.SqrDistanceToHeroFrom(Position))));
            chase.AddTransition(new Transition(idle, () => (Math.Pow(distanceToBeginChase, 2) < EnemyDirector.Instance.SqrDistanceToHeroFrom(Position))));
            shoot.AddTransition(new Transition(chase, () => (Math.Pow(distanceToBeginShoot, 2) < EnemyDirector.Instance.SqrDistanceToHeroFrom(Position)) && !shoot.InAttack));

            // Dead Player - All states back to idle
            // ?


            // Add the created states to the FSM
            stateMachine.AddState(idle);
            stateMachine.AddState(chase);
            stateMachine.AddState(shoot);



            // Collider Related
            colliderSize = new Vector2Int(2, 2);
            BoundingRect = new Rectangle((int)Position.X, (int)Position.Y, colliderSize.X, colliderSize.Y);

            base.OnPoolInstantiation();
        }
示例#3
0
        public override void OnPoolInstantiation()
        {
            // Stats
            MoveSpeed = 100.0f;
            DrawColor = Color.White;

            Animator = new Animator();

            EnemyAnimations = EnemyDirector.Instance.DogeAnimations;
            // Position = new Vector2(0);

            stateMachine = new NPCStateMachine(this);

            // Create the states
            IdleState             idle             = new IdleState("idle");
            ChaseState            chase            = new ChaseState("chase");
            ShortRangeAttackState shortRangeAttack = new ShortRangeAttackState("shortRangeAttack", 2.0f, 1.5f, true);

            // Create the transitions between the states
            idle.AddTransition(new Transition(chase, () => (Math.Pow(distanceToBeginChase, 2) >= EnemyDirector.Instance.SqrDistanceToHeroFrom(Position))));
            chase.AddTransition(new Transition(shortRangeAttack, () => (Math.Pow(distanceToBeginAttack, 2) >= EnemyDirector.Instance.SqrDistanceToHeroFrom(Position))));
            chase.AddTransition(new Transition(idle, () => (Math.Pow(distanceToBeginChase, 2) < EnemyDirector.Instance.SqrDistanceToHeroFrom(Position))));
            shortRangeAttack.AddTransition(new Transition(chase, () => (Math.Pow(distanceToBeginAttack, 2) < EnemyDirector.Instance.SqrDistanceToHeroFrom(Position)) && !shortRangeAttack.InAttack));


            // Add the created states to the FSM
            stateMachine.AddState(idle);
            stateMachine.AddState(chase);
            stateMachine.AddState(shortRangeAttack);

            //// Set the starting state of the FSM
            //stateMachine.Initialise("idle");

            // Collider Related
            colliderSize = new Vector2Int(2, 2);
            BoundingRect = new Rectangle((int)Position.X, (int)Position.Y, colliderSize.X, colliderSize.Y);

            base.OnPoolInstantiation();
        }