Exemplo n.º 1
0
    private void Update()
    {
        if (timer > timeBeforeRepair)
        {
            timer = 0;
            foreach (var playerToRepair in playersInsideTrigger)
            {
                if (playerToRepair.currenthealth < playerToRepair.maxHealth)
                {
                    GlobalMediator.SendMessage(GameEvents.PLAYER_REPAIRED, new PlayerData {
                        id = playerToRepair.playerNumber
                    });
                }
            }
        }
        else
        {
            timer += Time.deltaTime;
        }

        if (playersInsideTrigger.Count == 0)
        {
            timer = 0;
        }
    }
Exemplo n.º 2
0
    private void FixedUpdate()
    {
        // var hit = Physics2D.CircleCast(transform.position + Vector3.up, circleRaduis, Vector2.down, rayDistance, mask);

        var hit = Physics2D.OverlapCircle(transform.position + (Vector3.up * cirlceOffsetY), circleRaduis, mask);

        if (hit)
        {
            if (!isGrounded)
            {
                isGrounded = true;
                GlobalMediator.SendMessage(GameEvents.PLAYER_GROUND_CHECK, new GroundCheckData
                {
                    id         = playerNumber,
                    isGrounded = true
                });
            }
        }
        else
        {
            if (isGrounded)
            {
                isGrounded = false;
                GlobalMediator.SendMessage(GameEvents.PLAYER_GROUND_CHECK, new GroundCheckData
                {
                    id         = playerNumber,
                    isGrounded = false
                });
            }
        }
    }
Exemplo n.º 3
0
    private void FixedUpdate()
    {
        if (isMounted && mountedPlayer != null)
        {
            var hit = Physics2D.CircleCast(transform.position, circleRaduis, Vector2.up, rayDistance, mask);

            if (hit)
            {
                if (!WallOver)
                {
                    WallOver = true;
                    GlobalMediator.SendMessage(GameEvents.PLAYER_FORCE_DISMOUNT, new PlayerData
                    {
                        id = mountedPlayer.GetComponent <Player>().playerNumber,
                    });
                }
            }
            else
            {
                if (WallOver)
                {
                    WallOver = false;
                    //Send so we can't go to the direction
                }
            }
        }
        else
        {
            WallOver = false;
        }
    }
Exemplo n.º 4
0
 public static void Initialize()
 {
     shakeObj = new GameObject("@Screenshake Object");
     shakeObj.transform.position = Vector3.zero;
     UnityEngine.Object.FindObjectOfType <Camera>().transform.SetParent(shakeObj.transform, true);
     GlobalMediator.AddListener(RecieveEvents);
 }
Exemplo n.º 5
0
    public override void Initialize(int playerNumber)
    {
        base.Initialize(playerNumber);
        allowedToMove = false;
        InputManager.SetPlayerNumberUpdateDevice(playerNumber, InputManager_OnChanges);
        InputManager_OnChanges();

        GlobalMediator.AddListener(RecieveEvents);
    }
Exemplo n.º 6
0
 private void DismountPlayer()
 {
     if (mountedPlayer)
     {
         GlobalMediator.SendMessage(GameEvents.PLAYER_GOT_DISMOUNTED, new PlayerData
         {
             id = mountedPlayer.GetComponent <Player>().playerNumber
         });
     }
     mountedPlayer = null;
     isRiding      = false;
 }
Exemplo n.º 7
0
 public void RespawnPlayers()
 {
     GlobalMediator.SendMessage(GameEvents.PLAYER_RESPAWN, new PlayerRespawnData
     {
         id       = 1,
         position = player1SpawnPoint.position
     });
     GlobalMediator.SendMessage(GameEvents.PLAYER_RESPAWN, new PlayerRespawnData
     {
         id       = 2,
         position = player2SpawnPoint.position
     });
 }
Exemplo n.º 8
0
 private void MountPlayer(GameObject bottomPlayer)
 {
     if ((GetComponent <Rigidbody2D>().velocity.y > 0) || !bottomPlayer.GetComponent <Movement>().isGrounded)
     {
         return;
     }
     mountedPlayer      = bottomPlayer.transform;
     transform.position = mountedPlayer.position + new Vector3(0, yOffset, 0);
     isRiding           = true;
     GlobalMediator.SendMessage(GameEvents.PLAYER_GOT_MOUNTED, new PlayerGotMountedData
     {
         id            = bottomPlayer.GetComponent <Player>().playerNumber,
         playerMounted = transform
     });
 }
Exemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        // if (Gamepad.current.buttonSouth.wasPressedThisFrame)
        // {
        //     AkSoundEngine.PostEvent("player_repair", this.gameObject);
        // }

        // if (!allowedToMove) return;
        GlobalMediator.SendMessage(GameEvents.PLAYER_INPUT, new PlayerInputData
        {
            id          = playerNumber,
            axis        = inputs.Player.Movement.ReadValue <Vector2>(),
            key_charge  = holdingCharge,
            key_respawn = inputs.Player.Respawn.triggered,
        });
    }
Exemplo n.º 10
0
    public override void Initialize(int playerNumber)
    {
        base.Initialize(playerNumber);
        GlobalMediator.AddListener(this);
        spriteRenderer  = GetComponent <SpriteRenderer>();
        foundAnimations = new Dictionary <string, Sprite[]>();
        foundInfo       = new Dictionary <string, UnitAnimationInfo>();


        myCharacter       = playerNumber == 1 ? Character.Blue : Character.Pink;
        myCharacterFolder = (myCharacter is Character.Blue) ? BlueFolder : PinkFolder;


        TryStartAnimation("Idle");
        SetFrameRate("Idle");
        NextFrame();
    }
    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.CompareTag(tagToTriggerOn) && collision.transform != transform.parent)
        {
            objectsInside.Remove(collision.gameObject);

            if (objectsInside.Count == 0)
            {
                GlobalMediator.SendMessage(eventsToTrigger, new PlayerTriggerBoxData
                {
                    id              = playerNumber,
                    enterExit       = false,
                    collidingObject = collision.gameObject
                });
            }
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag(tagToTriggerOn))
        {
            if (!objectsInside.Contains(collision.gameObject))
            {
                objectsInside.Add(collision.gameObject);
            }

            GlobalMediator.SendMessage(eventsToTrigger, new PlayerTriggerBoxData
            {
                id              = playerNumber,
                enterExit       = true,
                collidingObject = collision.gameObject
            });
        }
    }
Exemplo n.º 13
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (!active)
        {
            return;
        }
        if (collision.CompareTag("Player"))
        {
            playersInGoal++;

            if (playersInGoal == necessaryPeopleInGoal)
            {
                active = false;
                GlobalMediator.SendMessage(GameEvents.LEVEL_WON);
            }
        }
    }
Exemplo n.º 14
0
 private void Start()
 {
     GlobalMediator.SendMessage(GameEvents.GAME_STARTED);
 }