private GameObject prefabObject;    // The actual location of the prefab that is moving


    // MONO FUNCTIONS ----------------------------------------------------------------------------- |

    /*
     * This function is called when the game is booted and is used for initializations.
     *
     */
    void Start()
    {
        enter = transform.GetComponentInChildren <TriggerEnter>();
        // Event listeners
        IDied.AddListener(nullPing);
        IGotHit.AddListener(nullPing2);
        IShot.AddListener(nullPing2);
        IPerformed.AddListener(nullPing3);
        enter.addItemListener(triggered);

        speedDisplay = prefabObject.transform.Find("SpeedUp").gameObject;
        powerDisplay = prefabObject.transform.Find("Power").gameObject;
        speedDisplay.SetActive(false);
        powerDisplay.SetActive(false);

        gm = GameObject.Find("Main Camera").GetComponent <GameManager>();
        gm.addDamageListener(MyTeam, playerNumber, RecordHit);

        anim = prefabObject.transform.Find("Space_Soldier_A_LOD1").GetComponent <Animator>();
        part = prefabObject.GetComponent <ParticleSystem>();

        visible = new List <GameObject>();
        visibleEnemyLocations = new List <Vector3>();
        attackedFromLocations = new List <Vector3>();

        moveDestination = prefabObject.transform.position;

        // These functions are called every second. useful for timers and other time based events
        InvokeRepeating("reloadTimerCountdown", 0.0f, 1.0f);
        InvokeRepeating("respawnTimerCountdown", 0.0f, 1.0f);
        InvokeRepeating("enemyLocationTimerCountdown", 0.0f, 1.0f);
    }
示例#2
0
    // If the parameter is not already in the map, adds the ActionableGameObject-ActionEvent pair to the map with a new ActionEvent. Then subscribes the ActionableGameObject to the ActionEvent.
    public void Subscribe(ActionableGameObject owner)
    {
        ActionEvent actionEvent;

        if (!eventMap.ContainsKey(owner))
        {
            actionEvent = new ActionEvent();
            eventMap.Add(owner, actionEvent);

            UnityAction <Action> callback = owner.OnActionEvent;
            actionEvent.AddListener(callback);
        }
    }
 public void AddListener(UnityAction action)
 {
     boundEvent.AddListener(action);
 }