Esempio n. 1
0
    virtual public void Hit(GameObject target, bool facingRight, bool fromCollsion)
    {
        BattleStats stats = target.GetComponent <BattleStats>();

        stats.health -= attacks[currentAttackIndex].damage;

        DefaultBattleScript targetBattleScript = target.gameObject.GetComponent <DefaultBattleScript>();

        if (stats.health == 0)
        {
            doubleHop = false;

            FindObjectOfType <BattleSceneManager>().RemoveEntity(targetBattleScript);

            if (target.gameObject.GetComponent <GreggBattleScript>())
            {
                GreggBattleScript enemy = target.gameObject.GetComponent <GreggBattleScript>();

                foreach (BattleMenu menu in FindObjectsOfType <BattleMenu>())
                {
                    menu.RemoveEnemy(enemy);
                }
            }

            targetBattleScript.currentState = States.DEAD;
        }
        else
        {
            targetBattleScript.currentState = States.ATTACKED;
        }

        if (currentCoroutine != null && fromCollsion)
        {
            StopCoroutine(currentCoroutine);
            currentCoroutine = null;
        }

        if (doubleHop)
        {
            rb.velocity = new Vector3(0.0f, hopHeight, rb.velocity.z);

            doubleHop = false;
        }
        else
        {
            if (fromCollsion)
            {
                rb.velocity = new Vector3(-moveSpeed, hopHeight / 2, rb.velocity.z);

                currentState = States.RETREAT;

                currentCoroutine = StartCoroutine(RetreatBehavior(facingRight));
            }

            target.gameObject.layer = targetBattleScript.initLayer;
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        currentState = States.EXPANDING;

        player = FindObjectOfType <GiuseppeBattleScript>();
        gregg  = FindObjectOfType <GreggBattleScript>();

        // set ui components
        menu.transform.localScale = new Vector3(0.0f, 0.0f, 1.0f);
        scrollRect = menu.GetComponentInChildren <ScrollRect>();
        content    = scrollRect.viewport.GetComponentInChildren <RectTransform>();
        knife      = scrollRect.transform.Find("Knife").GetComponent <Image>();

        SetMenuItems();

        menuRange = new Vector2Int(0, attacks.Length - 1);
        i         = menuRange.x;

        scroll       = true;
        playerAttack = true;

        StartCoroutine(Wait());
    }
Esempio n. 3
0
 public void RemoveEnemy(GreggBattleScript gregg)
 {
     greggs.Remove(gregg);
     greggRange.y--;
 }