示例#1
0
    IEnumerator HideOver()
    {
        //set fathers new row
        if (transform.position.x < GameManager.instance.playerController.transform.position.x)
        {
            row = bodyToHideOn.leftRow;
        }
        else
        {
            row = bodyToHideOn.rightRow;
        }
        stateBoss = State.HideOver;
        yield return(new WaitForSeconds(1.958f)); // hide over time

        Reposition();
        bodyToHideOn = null;
        int   random = Random.Range(0, 2);
        float dg     = 0;

        if (random == 0)
        {
            dg = 90;
        }
        else
        {
            dg = -90;
        }
        Reposition();
        StartCoroutine("Turn", dg);
    }
示例#2
0
    void ChooseNewPosition()
    {
        int random = 1;

        if (health.health < health.maxHealth / 2 && deadBodies.Count > 0)
        {
            random = Random.Range(0, 2);
            if (random == 1) // try to find a dead body
            {
                print("random is " + random);
                List <FatherBossDeadBodyController> newBodiesList = new List <FatherBossDeadBodyController>();
                foreach (FatherBossDeadBodyController i in deadBodies)
                {
                    Vector3 iPos = new Vector3(i.transform.position.x, GameManager.instance.playerController.transform.position.y, i.transform.position.z);
                    if (Vector3.Distance(iPos, GameManager.instance.playerController.transform.position) > 6) // add body to list if it's far enough
                    {
                        newBodiesList.Add(i);
                    }
                }
                print(newBodiesList.Count);
                if (newBodiesList.Count > 1 && deadBodies.Count > 13)
                {
                    //choose one body
                    bodyToHideOn = newBodiesList[Random.Range(0, newBodiesList.Count)];
                    // choose row
                    int r = Random.Range(0, 2);
                    if (r == 0)
                    {
                        newRow = bodyToHideOn.leftRow;
                    }
                    else
                    {
                        newRow = bodyToHideOn.rightRow;
                    }
                }
                else
                {
                    random       = 0;
                    bodyToHideOn = null;
                }
            }
        }
        else
        {
            random = 0;
        }

        if (random == 0) // choose new row to Sleep
        {
            rowList = new List <int>();
            for (int i = 0; i < 5; i++)
            {
                if (i != row)
                {
                    //print(i);
                    rowList.Add(i);
                }
            }
            newRow   = rowList[Random.Range(0, 4)];
            newPlace = Random.Range(0, 2);
        }
    }