Пример #1
0
    public IEnumerator ProceedToIncarnate(Creature zCreatureYouWhere, Creature zCreatureYouWillBecome)
    {
        Debug.Log("Incarnate from " + zCreatureYouWhere.name + " to " + zCreatureYouWillBecome.name);

        DestroyAllHitboxes();

        //Health fix
        zCreatureYouWhere.health = zCreatureYouWhere.maxhealth;
        zCreatureYouWillBecome.health = zCreatureYouWillBecome.maxhealth;
        zCreatureYouWhere.Graphic.LifeBar.Hide();
        zCreatureYouWillBecome.Graphic.LifeBar.Hide();

        //Deplete your incarnation energy
        IngameUI.Instance.PlayerIncarnation = 0;

        //The killed creature gets its Brain destroyed
        Destroy(zCreatureYouWhere.Brain);
        yield return new WaitForEndOfFrame();

        //The killer creature swaps its brain for a PlayerInput component
        Brain oldBrain = zCreatureYouWillBecome.GetComponent<Brain>();
        Destroy(oldBrain);
        yield return new WaitForEndOfFrame();

        Brain newBrain = zCreatureYouWillBecome.gameObject.AddComponent<PlayerInput>();
        zCreatureYouWillBecome.GetBrain();
			GameEvent("ChangeForm");

        //We kill the old creature
        zCreatureYouWhere.EffectsWhenDestroyed();
        Destroy(zCreatureYouWhere.gameObject);
        yield return new WaitForEndOfFrame();


        IngameUI.Instance.TotemManager.Refresh();

    }