示例#1
0
 public void AddBomb()
 {
     if (!_isDead && _currentBombCount > 0)
     {
         OnPlantBomb?.Invoke(this);
         OnBombCountChange?.Invoke(this);
     }
 }
示例#2
0
    void OnJoin(NetworkAction action)
    {
        Debug.Log("OnJoin data " + action.data);
        string ip      = action.senderIp;
        string session = action.senderSession;

        RegisterPlayer(ip, session);
        playerListChanged.Invoke(GetEnemies());
    }
 private void AddPlayer(ConnectionInfos infos)
 {
     for (int i = 0; i < connectedPlayers.Length; i++)
     {
         if (connectedPlayers[i] == null)
         {
             keysPressed[infos.accessKey] = true;
             connectedPlayers[i]          = infos;
             OnPlayerEvent.Invoke(i, infos, true);
             break;
         }
     }
 }
示例#4
0
 private void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.gameObject.CompareTag("enemybullet"))
     {
         OnHit.Invoke();
     }
 }
示例#5
0
 void OnReady(PlayerBehavior player)
 {
     if (PlayerReady != null)
     {
         PlayerReady.Invoke(this);
     }
 }
示例#6
0
 public void RemovePlayer(Player player)
 {
     players.Remove(player);
     playerDisplayed[playerCount] = null;
     playerCount++;
     OnPlayerRemove.Invoke(player);
 }
示例#7
0
    private void CheckForItemInLineOfSight()
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, pickupRange))
        {
            if (hit.collider.tag == itemTag)
            {
                Debug.Log("Seeing " + hit.collider.gameObject.name);

                ItemSeenEvent.Invoke(hit.collider.gameObject);

                if (Input.GetKeyUp(KeyCode.E))
                {
                    // call item event to add to inventory
                    ItemPickupEvent.Invoke(hit.collider.gameObject);

                    // play Pickup Animation
                    PlayPickupAnim();
                }
            }
        }
        else
        {
            UIHandler.DisableItemPickup.Invoke(null);
        }
    }
示例#8
0
    public virtual void Kill(Player killer)
    {
        if (_isDead)
        {
            return;
        }

        _isDead = true;

        // Suicide?
        if (killer != null)
        {
            if (killer.Id == Id)
            {
                //Debug.Log($"Player just suicide himself...");
                UpdateScore(-2);
            }
            else
            {
                Debug.Log($"Player killed by {killer.Id}");
            }
        }

        SoundManager.Instance.PlaySound("PlayerDeath");

        _animator.SetBool("IsDead", _isDead);

        OnDeath?.Invoke(this);
    }
示例#9
0
        /// <summary>
        /// Remove Player by Name
        /// </summary>
        /// <param name="Name">Player Name</param>
        /// <param name="Reason">Reason</param>
        public void Remove(string Name, string Reason)
        {
            Player Player = GetPlayer(Name);

            Player.Network.IsActive = false;

            if (Player.isGameJoltPlayer)
            {
                Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server."), null));
                Core.Logger.Log(Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server with the following reason: " + Reason), Logger.LogTypes.Info);

                OnlineSetting OnlineSetting = (from OnlineSetting p in Core.Setting.OnlineSettingListData where p.GameJoltID == Player.GameJoltID select p).FirstOrDefault();
                OnlineSetting.Save();
                Core.Setting.OnlineSettingListData.Remove(OnlineSetting);
            }
            else
            {
                Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server."), null));
                Core.Logger.Log(Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server with the following reason: " + Reason), Logger.LogTypes.Info);
            }

            Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.DestroyPlayer, Player.ID.ToString(), null));

            if (Reason != Core.Setting.Token("SERVER_PLAYERLEFT"))
            {
                Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Reason, Player.Network.Client));
            }

            Core.RCONPlayer.SendToAllPlayer(new RCON_Client_Listener.Packages.Package(RCON_Client_Listener.Packages.Package.PackageTypes.RemovePlayer, $"{Player.ID},{Player.ToString()}", null));

            Player.Network.ThreadPool3.WaitForIdle();

            PlayerEvent.Invoke(PlayerEvent.Types.Remove, $"{Player.ID},{Player.ToString()}");
            Core.Player.Remove(Player);
        }
示例#10
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Enemy")
     {
         IDied?.Invoke();
     }
 }
示例#11
0
		/// <summary>
		/// Stop method
		/// </summary>
		public void Stop()
		{
			if(CanStop)
			{
				PlayerEvent?.Invoke(this, new PlayerEngineEvent() { EventType = PlayerEventType.Stop, Message = "Stopped" });
				OnStop();
			}
		}
示例#12
0
 public void AddDamage(int damageAmount)
 {
     this.currentHp -= damageAmount;
     if (this.currentHp <= 0)
     {
         onDead.Invoke(this.player);
     }
 }
示例#13
0
 public void AddPlayer(Player player)
 {
     Debug.Log($"JOINED: {player.Name}");
     players.Add(player);
     playerDisplayed[playerCount] = player;
     playerCount++;
     OnPlayerAdd.Invoke(player);
 }
示例#14
0
		/// <summary>
		/// Pause method
		/// </summary>
		public void Pause()
		{
			if(CanPause)
			{
				PlayerEvent?.Invoke(this, new PlayerEngineEvent() { EventType = PlayerEventType.Pause, Message = "Paused" });
				OnPause();
			}
		}
示例#15
0
    void OnTriggerExit(Collider collider)
    {
        Entity_Player player = collider.GetComponent <Entity_Player>();

        if (player != null)
        {
            ExitEvent.Invoke(player);
        }
    }
示例#16
0
    private void Update()
    {
        if (transform.position != _previousPosition)
        {
            OnMove?.Invoke(this);
        }

        _previousPosition = transform.position;
    }
示例#17
0
    void PlayerInput()
    {
        if (PlayerEnabled)
        {
            float sw = Input.GetAxis("Mouse ScrollWheel");

            if (sw != 0)
            {
                DigSizeClick = Mathf.Clamp(DigSizeClick + 0.5f * sw, 1.5f, 8f);
                DigSize      = Mathf.Floor(DigSizeClick * 10) / 10.0f;
            }

            moveInput.x   = Input.GetAxisRaw("Horizontal");
            moveInput.y   = Input.GetAxisRaw("Vertical");
            mc.InputMove  = moveInput;
            mc.InputJump |= Input.GetButton("Jump");

            mc.InputSprint = Input.GetButton("Sprint");
            if (Input.GetButton("Fire1"))
            {
                if (digIntervalTimer <= 0 && !IsOverHeating)
                {
                    Dig();
                }
            }
            if (Input.GetButtonDown("Fire2"))
            {
                if (InRangeState != InRange.Nothing && GrappleTimer >= grappleInterval)
                {
                    grapplingHook.Grapple(hit.point);
                }
            }
            else if (Input.GetButtonUp("Fire2") && grapplingHook.isGrappled)
            {
                GrappleTimer = 0;
                grapplingHook.UnGrapple();
            }



            if (Input.GetButtonDown("Interact") && InRangeState == InRange.Interactible)
            {
                hit.collider.GetComponent <Interactible>().Interact();
            }

            if (Input.GetButtonDown("Sonar"))
            {
                OnListenSonar?.Invoke(this);
            }
            else if (Input.GetButtonUp("Sonar"))
            {
                OnStopListenSonar?.Invoke(this);
            }
        }
    }
示例#18
0
    void Damage(PlayerLife life)
    {
        CurrentLife -= m_currentDamage;
        print("Damage " + playerNumber + " " + CurrentLife);

        //animação e audio de dano
        if (CurrentLife <= 0)
        {
            OnDeath.Invoke(this);
        }
    }
示例#19
0
        private void OnReceiveAuthenticate(NetworkConnection arg1, ReceiveAuthenticateMessage arg2)
        {
            var conn = _connections.Find(c => c.ConnectionId == arg1.connectionId);

            if (conn != null)
            {
                conn.PlayFabId       = arg2.PlayFabId;
                conn.IsAuthenticated = true;
                OnPlayerAdded.Invoke(arg2.PlayFabId);
            }
        }
示例#20
0
        private void OnReceiveAuthenticate(NetworkConnection nconn, ReceiveAuthenticateMessage message)
        {
            var conn = _connections.Find(c => c.ConnectionId == nconn.connectionId);

            if (conn != null)
            {
                conn.PlayFabId       = message.PlayFabId;
                conn.IsAuthenticated = true;
                OnPlayerAdded.Invoke(message.PlayFabId);
            }
        }
示例#21
0
        /// <summary>
        /// Add New Player to the collection.
        /// </summary>
        /// <param name="p">Package Data</param>
        public void Add(Package p)
        {
            if (p.IsValid && p.IsFullPackageData())
            {
                int    ID     = GetNextValidID();
                Player Player = new Player(p, ID);

                Core.RCONPlayer.SendToAllPlayer(new RCON_Client_Listener.Packages.Package(RCON_Client_Listener.Packages.Package.PackageTypes.AddPlayer, $"{ID},{Player.ToString()}", null));
                PlayerEvent.Invoke(PlayerEvent.Types.Add, $"{ID},{Player.ToString()}");
            }
        }
        private void OnReceiveAuthenticate(NetworkMessage netMsg)
        {
            var conn = _connections.Find(c => c.ConnectionId == netMsg.conn.connectionId);

            if (conn != null)
            {
                var message = netMsg.ReadMessage <ReceiveAuthenticateMessage>();
                conn.PlayFabId       = message.PlayFabId;
                conn.IsAuthenticated = true;
                OnPlayerAdded.Invoke(message.PlayFabId);
            }
        }
示例#23
0
 public void Withdraw(int sum)
 {
     if (sum > Money)
     {
         PlayerEvent.Invoke($"Player {Index} has not enough money");
     }
     else
     {
         Money -= sum;
         PlayerEvent.Invoke($"{sum} removed for Player {Index} account");
     }
 }
        private void OnReceiveAuthenticate(NetworkConnection connection, ReceiveAuthenticateMessage netMsg)
        {
            var conn = _connections.Find(c => c.ConnectionId == connection.connectionId);

            if (conn != null)
            {
                conn.PlayFabId       = netMsg.PlayFabId;
                conn.IsAuthenticated = true;
                OnPlayerAdded.Invoke(netMsg.PlayFabId);
                Debug.Log($"Player {netMsg.PlayFabId} is added.");
            }
        }
        private void OnReceiveAuthenticate(NetworkConnection netConn, ReceiveAuthenticateMessage netMsg)
        {
            Debug.Log("[UnityNetworkServer].Authenticate received");
            var conn = _connections.Find(c => c.ConnectionId == netConn.connectionId);

            if (conn != null)
            {
                var message = netMsg;
                conn.PlayFabId       = message.PlayFabId;
                conn.IsAuthenticated = true;
                OnPlayerAdded.Invoke(message.PlayFabId);
            }
        }
示例#26
0
    private void SetWinner()
    {
        gameOver = true;

        if (winEvent != null)
        {
            winEvent.Invoke(winner);
        }
        else
        {
            Debug.LogError("Cannot invoke win event: event is null!");
        }
    }
示例#27
0
    public void UpdatePower(int amount, bool reset = false)
    {
        if (reset)
        {
            _bombPower = amount;
        }
        else
        {
            _bombPower += amount;
        }

        OnPowerChange?.Invoke(this);
    }
示例#28
0
    public void UpdateSpeedBonus(int amount, bool reset = false)
    {
        if (reset)
        {
            _speedBonus = amount;
        }
        else
        {
            _speedBonus += amount;
        }

        OnSpeedChange?.Invoke(this);
    }
        private void OnServerDisconnect(NetworkMessage netMsg)
        {
            var conn = _connections.Find(c => c.ConnectionId == netMsg.conn.connectionId);

            if (conn != null)
            {
                if (!string.IsNullOrEmpty(conn.PlayFabId))
                {
                    OnPlayerRemoved.Invoke(conn.PlayFabId);
                }
                _connections.Remove(conn);
            }
        }
示例#30
0
        public override void OnServerDisconnect(NetworkConnection conn)
        {
            base.OnServerDisconnect(conn);

            var uconn = _connections.Find(c => c.ConnectionId == conn.connectionId);

            if (uconn != null)
            {
                if (!string.IsNullOrEmpty(uconn.PlayFabId))
                {
                    OnPlayerRemoved.Invoke(uconn.PlayFabId);
                }
                _connections.Remove(uconn);
            }
        }