Example #1
0
 // Update is called once per frame
 void Update()
 {
     if (sensingComp.HasTargetToFollow())
     {
         state = RatState.CHASE;
         movingComp.EndPatrolling(state);
         GameObject target = sensingComp.GetTarget();
         moveToTargetComp.BeginChasing(state, target);
     }
     else
     {
         state = RatState.PATROL;
         movingComp.BeginPatrolling(state);
         moveToTargetComp.EndChasing(state);
     }
 }
Example #2
0
        public Rat(
            Animation staticAnimation,
            Animation playerFollowing,
            Animation attackAnimation,
            Vector2 position, Vector2 size, float directionAngle, ISound deathSound, Animation deadAnimation, ISound attackSound, ISound hitSound) : base(
                position, size, directionAngle, 20)
        {
            this.staticAnimation = staticAnimation;
            this.playerFollowing = playerFollowing;
            this.attackAnimation = attackAnimation;
            this.deathSound      = deathSound;
            this.deadAnimation   = deadAnimation;
            this.attackSound     = attackSound;
            this.hitSound        = hitSound;

            state = RatState.Static;
        }
Example #3
0
    public void ChangeBehaviour(RatState newState)
    {
        state = newState;

        switch (state)
        {
        case RatState.ATTACK:
            Attack();
            break;

        case RatState.TAKEDAMAGE:
            Defend();
            break;

        case RatState.IDLE:
            Idle();
            break;
        }
    }