Exemplo n.º 1
0
    private void EnemyHit(BaseEventInfo e)
    {
        HitEventInfo eventInfo = e as HitEventInfo;

        if (eventInfo != null && !eventInfo.ObjectHit.CompareTag("Player"))
        {
            GameObject playerThatShot = eventInfo.ObjectThatFired;
            GameObject hitObject      = eventInfo.ObjectHit;
            hitObject.SetActive(false);
            if (!playerScore.ContainsKey(playerThatShot))
            {
                playerScore.Add(playerThatShot, 1);
            }
            else
            {
                playerScore[playerThatShot]++;
                if (playerScore[playerThatShot] == winCondition)
                {
                    EliminateEventInfo winnerEvent = new EliminateEventInfo(playerThatShot);
                    EventHandler.Instance.FireEvent(EventHandler.EventType.FinaleWinEvent, winnerEvent);
                }
            }
            UpdatePlayerScoreEventInfo updateEventInfo = new UpdatePlayerScoreEventInfo()
            {
                Player = playerThatShot, Score = playerScore[playerThatShot]
            };
            EventHandler.Instance.FireEvent(EventHandler.EventType.UpdateScoreEvent, updateEventInfo);
        }
    }
    private void UpdatePlayerScore(BaseEventInfo e)
    {
        UpdatePlayerScoreEventInfo eventInfo = e as UpdatePlayerScoreEventInfo;

        if (eventInfo != null)
        {
            Player p = GameController.Instance.FindPlayerByGameObject(eventInfo.Player);
            playerScoreTexts[p.ID].gameObject.SetActive(true);
            playerScoreTexts[p.ID].text = eventInfo.Score.ToString(); // same animation as pointsystem
        }
    }
Exemplo n.º 3
0
    private void EnemyHit(BaseEventInfo e)
    {
        HitEventInfo eventInfo      = e as HitEventInfo;
        GameObject   playerThatShot = eventInfo.ObjectThatFired;
        GameObject   hitObject      = eventInfo.ObjectHit;

        if (hitObject.GetComponent <PinataBehaviour>() != null)
        {
            HandlePinataHitEvent(hitObject, playerThatShot);
        }
        else if (hitObject.GetComponent <MovingTarget>() != null)
        {
            HandleChickenShootingGalleryHitEvent(hitObject, playerThatShot);
        }
        if (eventInfo != null && !eventInfo.ObjectHit.CompareTag("Player"))
        {
            if (gameIsActive)
            {
                int pts = 1;
                if (hitObject.GetComponent <PinataBehaviour>() != null)
                {
                    pts = hitObject.GetComponent <PinataBehaviour>().Points;
                }
                else if (hitObject.GetComponent <MovingTarget>() != null)
                {
                    pts = hitObject.GetComponent <MovingTarget>().Points;
                }
                AssignPoints(playerThatShot, pts);
                Player p      = GameController.Instance.FindPlayerByGameObject(playerThatShot);
                var    points = new Dictionary <Player, int>();
                points.Add(p, pts);
                MinigameController.Instance.MinigamePointSystem.UpdateScore(points);
                UpdatePlayerScoreEventInfo updateEventInfo = new UpdatePlayerScoreEventInfo()
                {
                    Player = playerThatShot, Score = playerScore[playerThatShot]
                };
                EventHandler.Instance.FireEvent(EventHandler.EventType.UpdateScoreEvent, updateEventInfo);
            }
            Destroy(hitObject);
        }
    }
Exemplo n.º 4
0
    private void RegisterPickUp(BaseEventInfo e)
    {
        PickUpEventInfo pei = e as PickUpEventInfo;

        if (pei != null)
        {
            GameObject pickUp = pei.PickedUpObject;
            GameObject player = pei.PlayerThatPickedUp;
            int        pts    = pickUp.GetComponent <PickUp>().Points;
            AssignPoints(player, pts);
            Player p      = GameController.Instance.FindPlayerByGameObject(player);
            var    points = new Dictionary <Player, int>();
            points.Add(p, pts);
            MinigameController.Instance.MinigamePointSystem.UpdateScore(points);
            UpdatePlayerScoreEventInfo updateEventInfo = new UpdatePlayerScoreEventInfo()
            {
                Player = player, Score = playerScore[player]
            };
            EventHandler.Instance.FireEvent(EventHandler.EventType.UpdateScoreEvent, updateEventInfo);
        }
    }