Example #1
0
    private void UpdateUnits(float unitPercent)
    {
        //Debug.Log("Updating Units");
        int total    = (int)(firstSelect.Tower.StationedUnits * unitPercent);
        int newUnits = total - curUnitGroup.UnitCount;

        UnitController.AddUnitsToGroup(curUnitGroup, newUnits);
        curUnitGroup.PrepareUnits(firstSelect.Tower);
        //Debug.Log("Unit Count: " + curUnitGroup.UnitCount);
    }
Example #2
0
    //function that is called for a tower that is going to attack, but is waiting on an AI to send units to it
    public IEnumerator StartOverloadAttack(TowerBehavior destination, float percent, float time)
    {
        yield return(new WaitForSeconds(time));

        UnitGroup currentGroup = UnitController.CreateUnitGroupForFaction(myTower.Faction, (int)(myTower.StationedUnits * percent));

        currentGroup.PrepareUnits(myTower);
        myCoroutine = this.WaittoAttack(currentGroup, destination, 1f);
        AIController.CallCoroutine(myCoroutine);
    }
Example #3
0
    //function that can call for the current AI to start its attack
    public bool StartAttack(TowerBehavior destination, float percentage, float time)
    {
        if (percentage <= 0)
        {
            return(false);
        }

        UnitGroup currentGroup = UnitController.CreateUnitGroupForFaction(myTower.Faction, (int)(myTower.StationedUnits * percentage));

        currentGroup.PrepareUnits(myTower);
        myCoroutine = this.WaittoAttack(currentGroup, destination, time);
        AIController.CallCoroutine(myCoroutine);


        return(true);
    }
Example #4
0
    public void OnPointerDown(PointerEventData eventData)
    {
        var btn = Controller.GetTowerButton(eventData.position);

        if (btn != null && btn.Tower.Faction == FactionController.PlayerFaction)
        {
            // Soft select tower and prepare units for movement
            firstSelect = btn;
            //firstSelect.Tower.ShowAtmosphere();

            curUnitGroup = UnitController.CreateUnitGroupForFaction(btn.Tower.Faction, (int)(btn.Tower.StationedUnits * Controller.UnitPercent));
            curUnitGroup.PrepareUnits(btn.Tower);

            if (PlayerSelectedTower != null)
            {
                PlayerSelectedTower(btn);
            }
        }
    }