コード例 #1
0
    public void CheckIfDead()
    {
        RefreshHpBar();
        if (pinfo.stats.hpCur < 1)
        {
            int team = pinfo.GetTeam();

            if (team == 1)
            {
                GameObject canvas = GameObject.FindGameObjectWithTag("Canvas").gameObject;
                canvas.SetActive(false);
                spawner.enabled        = false;
                plr.transform.position = new Vector3(1, 1);
                PlayerController pcon = plr.GetComponent <PlayerController>();
                pcon.RefreshPosAsInt(new Vector2Int(1, 1));
                Spawner sp = GameObject.FindGameObjectWithTag("Assets").GetComponent <Spawner>();

                sp.spawns.Clear();
                gi.canContinue = true;
                DataTransferManager.canSave = true;
                plr.SetActive(false);
                gi.ec.Clear();
                sp.sm.spawnNow = false;
                for (int i = 0; i < pcon.pinfo.items.Length; i++)
                {
                    pcon.pinfo.items[i].ResetItem();
                }
                sp.sm.spawnNow = true;

                HiscoreController.UpdateHiscore();
                DataTransferManager.SaveHiscore();
                SceneManager.LoadScene("Hiscores", LoadSceneMode.Single);
            }

            if (team == 2)
            {
                DiceForPot();
                gi.gold += gi.wave * 5;
                gi.ec.Remove(ec);
                Vector2Int pos = pinfo.GetPos();
                MapDataController.map[pos.x, pos.y].RemoveNpc();
                spawner.sm.RemoveEC(ec);
                Target.RemoveTarget();
                Destroy(transform.root.gameObject);
            }
        }
    }