Esempio n. 1
0
    //Export fuction to get false if he mised else true.
    public void FireState(bool state)
    {
        if (state == true)
        {
            generalState = true;
        }
        else
        {
            generalState = false;
        }

        //if player mised , enemy shoot to the player. Run function ShootPlayer from enemy script.
        //and run the game over function.
        if (generalState)
        {
            //if enemy's heath is <0 then we destroy him and muve the player.
            if (Enemy.health <= 0)
            {
                float playerPosition = player_Rigidbody2D.gameObject.transform.position.x;
                float enemyPosition  = Enemy.transform.position.x;
                bool  playerFlipping = Enemy.PlayerFlipping;

                Enemy.KillTheEnemy();
                minYenemyPos = 9000;
                _armatureComponent.animation.Play("Walk_pistol");

                if (playerPosition < enemyPosition)
                {
                    if (playerFlipping)
                    {
                        PM.enemyPosition = enemyPosition - 0.15f;
                    }
                    else
                    {
                        PM.enemyPosition = enemyPosition;
                    }
                    PM._state = PlayerMuvement.MuvementState.right;
                }
                else
                {
                    if (playerFlipping)
                    {
                        PM.enemyPosition = enemyPosition + 0.25f;
                    }
                    else
                    {
                        PM.enemyPosition = enemyPosition;
                    }
                    PM._state = PlayerMuvement.MuvementState.left;
                }
            }
            else
            {
                PlayerShoted = false;
            }
        }
        else
        {
            Enemy.ShootPlayer();
            PlayerShoted = true;
            //generalState = false;
        }

        if (CurrentEnemyKilles == EnemyCount)
        {
            PlayerShoted = true;
            CUI.CompletedLvl();
        }
    }