private void Awake()
    {
        GameObject[] gameManagers = GameObject.FindGameObjectsWithTag("GameController");
        if (gameManagers.Length > 1)
        {
            foreach (GameObject obj in gameManagers)
            {
                if (obj == gameObject)                   // Skip self
                {
                    continue;
                }
                PointsTracker tracker = obj.GetComponent <PointsTracker>();
                if (tracker)
                {
                    tracker.Setup();
                }
            }

            Destroy(gameObject);             // Destroy self
            return;
        }
        else
        {
            DontDestroyOnLoad(gameObject);             // Keep self
        }

        Instance                      = this;
        waitUntilGameOver             = new WaitUntil(IsGameOver);
        waitForIncreasePointsInterval = new WaitForSecondsRealtime(increasePointsInterval);
        Setup();
    }
示例#2
0
    public void OnEnable()
    {
        Text          t      = GetComponent <Text> ();
        PointsTracker points = GameObject.FindGameObjectWithTag("GameController").GetComponent <PointsTracker> ();

        StringBuilder builder = new StringBuilder();

        builder.Append(header).Append('\n');
        builder.Append(civilian).Append(points.civiliansKilled).Append(" X ")
        .Append(points.pointsForCivilian).Append(" = ").Append(points.civiliansKilled * points.pointsForCivilian).Append('\n');
        builder.Append(guards).Append(points.guardsKilled).Append(" X ")
        .Append(points.pointsForGuard).Append(" = ").Append(points.guardsKilled * points.pointsForGuard).Append('\n');
        builder.Append(buildings).Append(points.buildingsBroken).Append(" X ")
        .Append(points.pointsForBuilding).Append(" = ").Append(points.buildingsBroken * points.pointsForBuilding).Append('\n');

        builder.Append(total).Append(points.PointTotal());

        t.text = builder.ToString();
    }
示例#3
0
 /// <summary>
 /// Attach the points tracker to this enemy.
 /// </summary>
 /// <param name="pointsTracker"></param>
 public void SetPointsTracker(PointsTracker pointsTracker)
 {
     _pointsTracker = pointsTracker;
 }