Ejemplo n.º 1
0
    void Awake()
    {
        this.PublisherManager = GameObject.FindGameObjectWithTag("Script Home").GetComponent <PublisherManager>();
        this.RandomizeBody();
        this.GroupID = Random.Range(1, 4);
        this.PublisherManager.Register(GroupID, OnMoveMessage);

        // Used for Throttling calls to Watch().
        this.TimeToWatch = 0.0f;
        this.StartTime   = Time.time;

        // Assign pikmini lifespan to be between 10 and 40 seconds.
        this.Lifespan        = Random.Range(10.0f, 40.0f);
        this.DeathTimer      = 0.0f;
        this.StartDeathTimer = Time.time;

        // Placeholder initialization to make compiler happy.
        Func <Color> chosenFunction = () => new Color(0, 0, 0);

        // Pick a random group color assignment at Watcher initialization.
        switch (this.GroupID)
        {
        case 1:
            chosenFunction = this.ColorBindings.GetGroup1Color;
            break;

        case 2:
            chosenFunction = this.ColorBindings.GetGroup2Color;
            break;

        case 3:
            chosenFunction = this.ColorBindings.GetGroup3Color;
            break;

        default:
            Debug.Log("Entered default case (this should not happen).");
            break;
        }

        this.Watcher = new ColorWatcher(chosenFunction, ChangeColor);
    }
    void Awake()
    {
        this.PublisherManager = GameObject.FindGameObjectWithTag("Script Home").GetComponent <PublisherManager>();
        this.RandomizeBody();
        this.RandomizeThrottle();
        this.GroupID        = Random.Range(1, 4);
        this.DeleteThrottle = Random.Range(10f, 40f);
        this.PublisherManager.Register(GroupID, OnMoveMessage);

        switch (this.GroupID)
        {
        case 1:
            ColorWatcher = new ColorWatcher(ColorBindings.GetGroup1Color, this.ChangeColor);
            break;

        case 2:
            ColorWatcher = new ColorWatcher(ColorBindings.GetGroup2Color, this.ChangeColor);
            break;

        case 3:
            ColorWatcher = new ColorWatcher(ColorBindings.GetGroup3Color, this.ChangeColor);
            break;
        }
    }