예제 #1
0
    void OnCaptured(Team newTeam)
    {
        if (owningTeam != newTeam)
        {
            UnitController teamController = TeamServices.GetControllerByTeam(newTeam);
            if (teamController != null)
            {
                teamController.AddBuildPoints(BuildPoints);
            }

            if (owningTeam != Team.Neutral)
            {
                // remove points to previously owning team
                teamController = TeamServices.GetControllerByTeam(owningTeam);
                if (teamController != null)
                {
                    teamController.AddBuildPoints(-BuildPoints);
                }
            }
        }

        owningTeam = newTeam;
        mat.color  = newTeam == Team.Green ? Color.green : Color.red;
    }