Ejemplo n.º 1
0
    //Function called externally when this player takes damage
    public void DamagePlayer(int damageDealt_ = 0)
    {
        //Nothing happens if the damage dealt is below 0.
        if (damageDealt_ < 0)
        {
            return;
        }

        //Nothing happens if this player is currently invulnerable
        if (this.invulnerableCounter > 0)
        {
            return;
        }

        this.currentHealth -= damageDealt_;

        //If the player's health hits 0, they die
        if (this.currentHealth <= 0)
        {
            //Starts the death sequence for this player
            this.currentHealth       = 0;
            this.invulnerableCounter = this.invulnerableTime;
            this.respawnCounter      = this.respawnTime;

            //Dispatches a player death event saying that this player died
            EVTData deathEVT = new EVTData();
            deathEVT.playerDeath = new PlayerDeathEVT(this.playerIDTag.playerID, this.playerIDTag.playerTeam);
            Manager_EventManager.TriggerEvent(PlayerDeathEVT.eventName, deathEVT);
        }
    }
Ejemplo n.º 2
0
 //Function called when this object collides with another object's trigger collider
 private void OnTrigger2DStart(Collider2D otherObj_)
 {
     //If the object hit is a goal
     if (otherObj_.gameObject.GetComponent <BallGoal>() != null)
     {
         //Dispatches a GoalScoredEVT to the event manager that sends data about the goal: the player who scored, the player's team, and the team that they scored against
         EVTData scoreEVT = new EVTData();
         scoreEVT.goalScored = new GoalScoredEVT(lastPlayerHit, lastPlayerHitsTeam,
                                                 otherObj_.gameObject.GetComponent <BallGoal>().teamGoalID);
         Manager_EventManager.TriggerEvent(GoalScoredEVT.eventName, scoreEVT);
     }
 }
    public void DispatchEvent(int index_)
    {
        //Only dispatches the EVT if there's a cooresponding string
        if (index_ < EventNamesToDispatch.Count)
        {
            Manager_EventManager.TriggerEvent(EventNamesToDispatch[index_]);
        }

        //Only dispatches the Unity Event if there's a cooresponding event
        if (index_ < UnityEventsToTrigger.Count)
        {
            UnityEventsToTrigger[index_].Invoke();
        }
    }
Ejemplo n.º 4
0
    //Changes the alpha of the screen darkness object on the global data object's canvas
    public void SetDarkness(float screenDarkness_)
    {
        ScreenManager.Darkness = 0.8f - screenDarkness_;

        if (ScreenManager.Darkness > 1)
        {
            ScreenManager.Darkness = 1;
        }
        else if (ScreenManager.Darkness < 0)
        {
            ScreenManager.Darkness = 0;
        }

        Manager_EventManager.TriggerEvent("ChangeDarkness");
    }
    // Update is called once per frame
    private void FixedUpdate()
    {
        //Dispatches the event for activating this player's power 1
        if (this.playerController.CheckButtonPressed(power1Button) || this.playerController.LeftTrigger > this.triggerDeadzone)
        {
            EVTData powerEVT = new EVTData();
            powerEVT.playerPowerActivate = new PlayerPowerActivateEVT(this.playerController.PlayerID, PowerSlot.MainPower, false);
            Manager_EventManager.TriggerEvent(PlayerPowerActivateEVT.eventName, powerEVT);
        }

        //Dispatches the event for activating this player's power 2
        if (this.playerController.CheckButtonPressed(power2Button) || this.playerController.RightTrigger > this.triggerDeadzone)
        {
            EVTData powerEVT = new EVTData();
            powerEVT.playerPowerActivate = new PlayerPowerActivateEVT(this.playerController.PlayerID, PowerSlot.SecondaryPower, true);
            Manager_EventManager.TriggerEvent(PlayerPowerActivateEVT.eventName, powerEVT);
        }
    }
 //Calls an empty event using the event name to dispatch
 public void DispatchEvent()
 {
     Manager_EventManager.TriggerEvent(EventNameToDispatch);
 }
 private void DispatchSoundChangeEvt()
 {
     Manager_EventManager.TriggerEvent("SoundSettingsChanged");
 }