Ejemplo n.º 1
0
    public void Fight(TransformDestinations _td)
    {
        House origin = _td.start.GetComponent <House>();
        House dest   = _td.end.GetComponent <House>();

        if (dest.house_type == GV.MUSHROOM_HOUSE_TYPE.MUSHROOM && dest.type != origin.type)
        {
            if (origin.house_type == GV.MUSHROOM_HOUSE_TYPE.FORGE)
            {
                dest.units -= (1 * GV.FORGE_DAMAGE_MULTIPLIER);
            }
            else
            {
                dest.units -= 1;
            }

            if (dest.units <= 0)
            {
                dest.GetComponent <Mushroom>().SwitchTeam();
            }
        }
        else
        {
            dest.units += 1;
        }

        GameObject.Destroy(_td.unit.gameObject);
    }
Ejemplo n.º 2
0
    private void RemoveUnitFromList(Transform _transform, List <TransformDestinations> _list)
    {
        TransformDestinations toRemove = null;

        foreach (TransformDestinations td in _list)
        {
            if (td.unit == _transform)
            {
                toRemove = td;
                break;
            }
        }

        _list.Remove(toRemove);
    }
Ejemplo n.º 3
0
    public void UpdateAIUnits(float _dt)
    {
        for (int i = aiUnits.Count - 1; i >= 0; i--)
        {
            TransformDestinations td = aiUnits[i];

            if (td.timePassed >= 0)
            {
                td.script.UpdateDestination(td.end);
            }

            td.timePassed += _dt;

            if (td.script.IsArrived())
            {
                UnitsManager.Instance.Fight(td);
                aiUnits.Remove(td);
            }
        }
    }
Ejemplo n.º 4
0
    public void SendPlayerUnits(Transform _start, Transform _end, float _percentage)
    {
        House _mStart = _start.GetComponent <House>();

        float unitsToSend = Mathf.Floor(_mStart.units * _percentage);
        float _startDelay = 0f;

        for (int i = 0; i < unitsToSend; i++)
        {
            GameObject go = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs/PlayerUnit"));
            go.transform.position = _start.position;
            go.transform.SetParent(unitParent.transform);
            go.GetComponent <Unit>().startDelay = _startDelay;

            TransformDestinations td = new TransformDestinations(go.transform, _start, _end, _startDelay);
            playerUnits.Add(td);

            _startDelay += GV.UNIT_SEND_INTERVAL;
        }

        _mStart.units -= unitsToSend;
    }