// Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _PhysicsProcess(float delta)
    {
        if (_state == MinotaurState.Dead)
        {
            return;
        }

        if (_state == MinotaurState.Idle)
        {
            _timeoutDuration -= 2f;
            if (_timeoutDuration <= 0)
            {
                _state           = MinotaurState.Walking;
                _timeoutDuration = IdleTimeout;
            }

            return;
        }

        if (_behindCheck.IsColliding())         // If the player is behind the Minotaur.
        {
            var body = _behindCheck.GetCollider();
            if (body != null)
            {
                var bodyAsNode = (Node2D)body;
                if (bodyAsNode.Name == "Player")
                {
                    _display.Scale = new Vector2(-1, 1);
                    _state         = MinotaurState.Attacking;

                    Speed *= ChangeDirection;

                    _groundCheck.Position *= new Vector2(-1, 1);
                }
            }
        }

        if (IsOnWall() || !_groundCheck.IsColliding())
        {
            Speed *= ChangeDirection;

            _groundCheck.Position *= new Vector2(-1, 1);

            _state = MinotaurState.Idle;
        }

        _movement.x = Speed;

        _movement.y = Gravity;

        if (_movement == Vector2.Zero)
        {
            _state = MinotaurState.Idle;
        }

        if (_state != MinotaurState.Attacking)
        {
            _movement = MoveAndSlide(_movement, _floor);
        }
    }
Exemple #2
0
 protected void ChangeState(MinotaurState state)
 {
     if (state != BossState)
     {
         BossState = state;
     }
 }
    public override void _Process(float delta)
    {
        // This is garbage, dont do this.
        if (_painDuration > 0)
        {
            _painDuration       -= delta;
            _sprite.SelfModulate = Color.Color8(255, 65, 65);
        }
        else
        {
            _sprite.SelfModulate = Color.Color8(255, 255, 255);
        }

        if (HitsToDestroy <= 0)
        {
            _state = MinotaurState.Dead;

            GetNodeOrNull <CollisionShape2D>("AreaShape2D")?.QueueFree();
            GetNodeOrNull <Area2D>("DamageArea")?.QueueFree();
        }

        UpdatePlayerState();
        UpdateAnimation();

        PlayPassiveSoundEffect();
    }
 public void _on_MinotaurDamageArea_body_entered(Node body)
 {
     if (body.Name == "Player")
     {
         _state = MinotaurState.Attacking;
     }
 }
    private void FollowPath()
    {
        if (index != pathArray.Count && timeSinceLastMove >= .075)
        {
            Node curNode = FindNextNode();

            Vector3 moveTowardsVector = new Vector3(curNode.position.x, transform.position.y, curNode.position.z);

            transform.position = Vector3.MoveTowards(transform.position, moveTowardsVector, curSpeed - 2);

            Debug.Log("I Am Moving + " + curNode.position);

            timeSinceLastMove = 0;

            SetPath();
        }
        else if (index == pathArray.Count)
        {
            curState = MinotaurState.Attack;
            index    = 0;
        }

        timeSinceLastMove += Time.deltaTime;
        Debug.Log(timeSinceLastMove);
    }
 //Things needed from the beginning
 protected void Initialize()
 {
     curState     = MinotaurState.Patrol;
     curSpeed     = 2.5f;
     wallDistance = 1.5f;
     pathArray    = new ArrayList();
     player       = GameObject.FindGameObjectWithTag("Player");
 }
    public void _on_AnimationPlayer_animation_finished(String anim_name)
    {
        if (_state == MinotaurState.Attacking)
        {
            _state = MinotaurState.Idle;
        }

        if (_state == MinotaurState.Dead || _animationState == MinotaurAnimationState.Death)
        {
            QueueFree();
        }
    }
    // Start is called before the first frame update
    public override void Start()
    {
        base.Start();

        minotaurState        = MinotaurState.Normal;
        knockbackTime        = 0.2f;
        knockbackCoefficient = 0.05f;
        attackStrength       = 25;

        beybladeVectorAr = new Vector2[] {
            new Vector2(20f, 20f),
            new Vector2(20f, -20f),
            new Vector2(-20f, 20f),
            new Vector2(-20f, -20f)
        };
    }
Exemple #9
0
 public override void TakeDamage(Transform thingThatHitYou, float pushTime, float pushForce, float damage, bool display = true)
 {
     if (!IsDead)
     {
         if (BossState != MinotaurState.Attacking)
         {
             BossState = MinotaurState.Staggered;
             Vector2 difference = transform.position - thingThatHitYou.position;
             difference = difference.normalized * pushForce / 3;
             body.AddForce(difference, ForceMode2D.Impulse);
         }
         if (transform.gameObject.activeInHierarchy)
         {
             StartCoroutine(Knockback(pushTime));
         }
         UpdateHealth(damage);
     }
 }
    public override void _Ready()
    {
        _state = MinotaurState.Walking;

        _timeoutDuration = IdleTimeout;

        _movement   = new Vector2();
        _animations = GetNode <AnimationPlayer>("AnimationPlayer");
        _sprite     = GetNode <Sprite>("Display/Sprite");
        _display    = GetNode <Node2D>("Display");

        _groundCheck = GetNode <RayCast2D>("GroundCheck");
        _behindCheck = GetNode <RayCast2D>("Display/BehindCheck");

        _damageArea = GetNode <Area2D>("Display/DamageArea");

        _audioStreamPlayer2D = GetNode <AudioStreamPlayer2D>("AudioStreamPlayer2D");
    }
    private void UpdatePatrolState()
    {
        RaycastHit hit;
        Ray        wallIntercept = new Ray(transform.position, this.transform.forward * wallDistance);

        Debug.DrawRay(transform.position, this.transform.forward * wallDistance);


        if (Physics.Raycast(wallIntercept, out hit, wallDistance))
        {
            if (hit.collider.tag == "Wall")
            {
                MakeTurnDecision();
            }
            if (hit.collider.tag == "Scent")
            {
                curState = MinotaurState.Smell;
            }
        }
        else
        {
            MoveForward();
        }
    }
 private void Attack()
 {
     curState = MinotaurState.Patrol;
 }