IEnumerator RespawnTimer()
    {
        jagMesh.GetComponent <Animation>().Play("death_anim");
        yield return(new WaitForSeconds(0.8f));

        if (isDying == true)
        {
            newMeat = (GameObject)Instantiate(rawMeat, this.transform.position, Quaternion.identity);
            Destroy(newMeat, 30);
            health  = 5;
            isDying = false;
            this.transform.position = AiController.transform.position;
            if (distanceFromPlayer < 50)
            {
                AiController.GetComponent <L_AIManager>().respawnIndexList.Add(listIndex); // this tells the AI manager what jaguar has died and stores that information so this script can be set active again when its time to respawn

                this.gameObject.SetActive(false);
            }
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        Debug.Log(score);
        currentAI.moveSpeed = AISpeedChange.value;
        PlayerPrefs.SetFloat("AI Speed", currentAI.moveSpeed);
        //scoreText.text = score.ToString();
        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            return;
        }

        if (isInteracable)
        {
            if (Input.GetKeyDown(KeyCode.M))
            {
                for (int i = 0; i < movement.Length; i++)
                {
                    if (movement[i] == "B")
                    {
                        count = i;
                        break;
                    }
                }
                currentAI.GetComponent <AiController>().isStart = true;
                isInteracable = false;
                count        += 1;
                currentAI.gameObject.SetActive(true);
                destroyAllChild(bonusParent);
                destroyAllChild(parent);
                for (int i = 0; i < m; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        if (bonus[i, j] != 0)
                        {
                            bonusPrefab.GetComponent <BonusManager>().updatePoint(bonus[i, j]);
                            Instantiate(bonusPrefab, new Vector2(j, m - 1 - i), Quaternion.identity, bonusParent);
                        }
                    }
                }
                scoreText.text = "0";
                score          = 0;
            }
            if (Input.GetKeyDown(KeyCode.Space))
            {
                if (movement[count] == "B")
                {
                    currentAI.GetComponent <AiController>().isStart = true;
                    isInteracable = false;
                    count        += 1;
                    currentAI.gameObject.SetActive(true);
                    destroyAllChild(parent);
                    for (int i = 0; i < m; i++)
                    {
                        for (int j = 0; j < n; j++)
                        {
                            if (bonus[i, j] != 0)
                            {
                                bonusPrefab.GetComponent <BonusManager>().updatePoint(bonus[i, j]);
                                Instantiate(bonusPrefab, new Vector2(j, m - 1 - i), Quaternion.identity, bonusParent);
                            }
                        }
                    }
                    scoreText.text = "0";
                    score          = 0;
                }
                destroyAllChild(parent);
                int miniX = 0;
                int miniY = 0;
                if (movement[count] == "P")
                {
                    destroyAllChild(bonusParent);
                    int x = Int32.Parse(movement[count + 2]);
                    int y = m - 1 - Int32.Parse(movement[count + 1]);
                    Instantiate(AIPrefab, new Vector2(x, y), Quaternion.identity, parent);
                    count         += 3;
                    scoreText.text = movement[count];
                    count         += 1;
                    for (int i = 0; i < 4; i++)
                    {
                        if (movement[count] != "F")
                        {
                            int temp = Int32.Parse(movement[count]);
                            samplePrefab.GetComponent <BonusManager>().updatePoint(temp);
                            if (i == 0)
                            {
                                Instantiate(samplePrefab, new Vector2(x, y + 1), Quaternion.identity, parent);
                            }
                            else if (i == 1)
                            {
                                Instantiate(samplePrefab, new Vector2(x + 1, y), Quaternion.identity, parent);
                            }
                            else if (i == 2)
                            {
                                Instantiate(samplePrefab, new Vector2(x, y - 1), Quaternion.identity, parent);
                            }
                            else if (i == 3)
                            {
                                Instantiate(samplePrefab, new Vector2(x - 1, y), Quaternion.identity, parent);
                            }
                        }
                        count += 1;
                    }
                    int nextBonusPoint = 0;
                    int temp2          = 0;
                    for (int i = 0; i < m; i++)
                    {
                        for (int j = 0; j < n; j++)
                        {
                            int bonusPoint = Int32.Parse(movement[count + temp2]);
                            if (bonusPoint != 0)
                            {
                                bonusPrefab.GetComponent <BonusManager>().updatePoint(bonusPoint);
                                Instantiate(bonusPrefab, new Vector2(j, m - 1 - i), Quaternion.identity, bonusParent);
                            }

                            if (movement[count + m * n] == "P")
                            {
                                nextBonusPoint  = Int32.Parse(movement[count + temp2 + 8 + m * n]);
                                miniBonus[i, j] = nextBonusPoint;
                            }
                            temp2 += 1;
                        }
                    }
                    if (movement[count + m * n] == "P")
                    {
                        miniX = Int32.Parse(movement[count + 1 + m * n]);
                        miniY = Int32.Parse(movement[count + 2 + m * n]);
                    }
                    count += m * n;
                }
                miniMap.GetComponent <BestMapDraw>().drawBonus(miniBonus, miniX, miniY);
            }
        }
        else
        {
            scoreText.text = score.ToString();
        }
    }