Exemple #1
0
    public void init(int str, UnitManager.Team tm)
    {
        strength = str;
        team     = tm;

        teamColor = (team == UnitManager.Team.Green ? Color.green : Color.red);

        switch (str)
        {
        case 1:
            color = Color.white;
            break;

        case 2:
            color = Color.blue;
            break;

        case 3:
            color = Color.yellow;
            break;

        case 4:
            color = Color.black;
            break;
        }
    }
Exemple #2
0
    //Add influence from a new unit
    public void AddInfluence(Vector3 unitPos, int strength, UnitManager.Team team)
    {
        //Calculate distance in grid spaces
        float dist = (unitPos - position).magnitude / 20;

        //Divide influence by dist
        float influence = strength;

        if (dist > 0)
        {
            influence /= dist;
        }

        //Increase influence for appropriate team
        if (team == UnitManager.Team.Green)
        {
            greeninfluence += influence;
        }
        else
        {
            redInfluence += influence;
        }

        //Update color for this space
        CalculateColor();
    }