Exemplo n.º 1
0
    private void OnClickFlee()
    {
        //TODO: incorporate the possibility of a variety of enemy ships
        //TODO: add some sort of randomness and a chance to fail, for if the ship is not hostile

        EnemyStatus.ShipHealthMax     = 50;
        EnemyStatus.ShipHealthCurrent = 50;
        EnemyStatus.GoldCount         = 50;
        EnemyStatus.ResourcesCount    = 20;
        SceneManager.LoadScene(SceneIndexes.Combat());
    }
Exemplo n.º 2
0
    private void FixedUpdate()
    {
        float horVel = Input.GetAxis("Horizontal");
        float verVel = Input.GetAxis("Vertical");

        //sprite.transform.eulerAngles = lastRotation;

        if (!moveLock)
        {
            speed           = new Vector2(horVel, verVel);
            player.velocity = speed * speedMult;
            //player.AddForce(speed * speedMult);
        }

        if (((horVel != 0) || (verVel != 0)) && !moveLock) //As long as a key is being pressed—!moveLock is included so it doesn't break in menus
        {
            zRotation = ((float)Math.Atan(player.velocity.y / player.velocity.x)) * (float)(180 / Math.PI);

            if (player.velocity.x >= 0)
            {
                lastRotation = new Vector3(0, 0, zRotation + 180);
                sprite.transform.eulerAngles = lastRotation;
            }
            else
            {
                lastRotation = new Vector3(0, 0, zRotation);
                sprite.transform.eulerAngles = lastRotation;
            }

            lastRotation = sprite.transform.eulerAngles;
        }


        if ((speed.x != 0) || (speed.y != 0)) //As long as the ship is in motion
        {
            depletionCounter++;               //Deplete resources
            if ((depletionCounter == depletionRate) && !moveLock)
            {
                PlayerStatus.ResourcesCount--;
                depletionCounter = 0;
            }


            float rand = UnityEngine.Random.value;

            if (rand > 1 - chanceHolder) //Check for random encounter
            {
                chanceHolder = .0001f;
                EnemyStatus.ShipHealthMax     = 50;
                EnemyStatus.ShipHealthCurrent = 50;
                EnemyStatus.GoldCount         = 50;
                EnemyStatus.ResourcesCount    = 20;
                SceneManager.LoadScene(SceneIndexes.Combat());
            }
            else
            {
                chanceHolder += encounterChance;
            }
        }

        PlayerStatus.ShipPos = transform.position;
    }