Ejemplo n.º 1
0
    void PlayerInput()
    {
        if (Input.GetMouseButtonUp(1))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.tag == "Enemy")
                {
                    CharacterType enemy = hit.collider.GetComponent <CharacterType>();

                    if (enemy.inRange)
                    {
                        enemy.TakeDamage(attackStrength);
                        Attacked();
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    public void Fight(CharacterType target)
    {
        switch (target.myType)
        {
        case cType.tNull:
            Debug.Log("Something's wrong");
            return;

        case cType.tArcher:
            Debug.Log("There shouldn't be an archer");
            break;

        case cType.tHeavy:

            switch (type)
            {
            case cType.tHeavy:
                target.TakeDamage(5);
                break;

            case cType.tSpear:
                target.TakeDamage(3);
                break;

            case cType.tSword:
                target.TakeDamage(8);
                break;

            default:
                Debug.Log("put the type in the prefab");
                break;
            }

            break;

        case cType.tSpear:

            switch (type)
            {
            case cType.tHeavy:
                target.TakeDamage(8);
                break;

            case cType.tSpear:
                target.TakeDamage(5);
                break;

            case cType.tSword:
                target.TakeDamage(3);
                break;

            default:
                Debug.Log("put the type in the prefab");
                break;
            }

            break;

        case cType.tSword:

            switch (type)
            {
            case cType.tHeavy:
                target.TakeDamage(3);
                break;

            case cType.tSpear:
                target.TakeDamage(8);
                break;

            case cType.tSword:
                target.TakeDamage(5);
                break;

            default:
                Debug.Log("put the type in the prefab");
                break;
            }

            break;

        default:
            System.Console.WriteLine("no type found");
            break;
        }
    }