Beispiel #1
0
 private static bool OpRaiseEvent(byte __0, Il2CppSystem.Object __1, Photon.Realtime.RaiseEventOptions __2, SendOptions __3) // events sent by you
 {                                                                                                                           // event code == 4
     if (__0 == 4)                                                                                                           // 4 is sending cached events
     {
         return(DataOKToSend(__1));
     }
     return(true);
 }
Beispiel #2
0
        /// <summary>
        /// Sends data to other clients or if debg echo then sends to all including this client
        /// </summary>
        /// <param name="samples">list of sampels that will be sent over network</param>
        private void SendDataToNetwork(List <float> samples)
        {
            // data in bytes to send over network
            byte[] bytes = AudioConverter.FloatToByte(samples);

            Photon.Realtime.RaiseEventOptions raiseEventOptions = new Photon.Realtime.RaiseEventOptions {
                Receivers = debugEcho ? Photon.Realtime.ReceiverGroup.All : Photon.Realtime.ReceiverGroup.Others
            };
            ExitGames.Client.Photon.SendOptions sendOptions = new ExitGames.Client.Photon.SendOptions {
                Reliability = reliableTransmission
            };
            Photon.Pun.PhotonNetwork.RaiseEvent(Constants.VoiceEventCode, bytes, raiseEventOptions, sendOptions);
        }
Beispiel #3
0
        /// <summary>
        /// Sends data to other clients or if debg echo then sends to all including this client
        /// </summary>
        /// <param name="samples">list of sampels that will be sent over network</param>
        private void SendDataToNetwork(List <float> samples)
        {
            //skip second with no sound
            if (!ripples.positiveInLastSecond)
            {
                return;
            }

            // data in bytes to send over network
            byte[] bytes = AudioConverter.FloatToByte(samples);

            List <int> targets = new List <int>();

            var speakers = proximity.listener.Speakers;

            // skip far away players since they don't hear the sound anyway
            foreach (int id in speakers.Keys)
            {
                //Debug.Log(speakers[id].AudioSource.volume);
                if (speakers[id].AudioSource.volume > 0)
                {
                    targets.Add(id);
                }
            }

            // add yourself if debugEcho = true
            if (debugEcho)
            {
                targets.Add(PhotonNetwork.LocalPlayer.ActorNumber);
            }

            if (targets.Count == 0)
            {
                return;
            }

            //Debug.Log("Send data");
            // sending data of recorded samples by using raise event feature
            Photon.Realtime.RaiseEventOptions raiseEventOptions = new Photon.Realtime.RaiseEventOptions {
                TargetActors = targets.ToArray()
            };
            //Photon.Realtime.RaiseEventOptions raiseEventOptions = new Photon.Realtime.RaiseEventOptions { Receivers = debugEcho ? Photon.Realtime.ReceiverGroup.All : Photon.Realtime.ReceiverGroup.Others };
            ExitGames.Client.Photon.SendOptions sendOptions = new ExitGames.Client.Photon.SendOptions {
                Reliability = reliableTransmission
            };
            Photon.Pun.PhotonNetwork.RaiseEvent(Constants.VoiceEventCode, bytes, raiseEventOptions, sendOptions);
        }
Beispiel #4
0
        private void OnPerformDrawCards(object sender, object args)
        {
            var drawAction = args as DrawCardsAction;

            int deckCount    = drawAction.Player.Deck.Count;
            int fatigueCount = Mathf.Max(drawAction.Amount - deckCount, 0);

            for (int i = 0; i < fatigueCount; i++)
            {
                var fatigueAction = new FatigueAction(drawAction.Player);
                Container.AddReaction(fatigueAction);
            }

            int roomInHand = Player.MaxHand - drawAction.Player.Hand.Count;
            int overdraw   = Mathf.Max((drawAction.Amount - fatigueCount) - roomInHand, 0);

            if (overdraw > 0)
            {
                var overdrawAction = new OverdrawAction(drawAction.Player, overdraw);
                Container.AddReaction(overdrawAction);
            }

            int drawCount = drawAction.Amount - fatigueCount - overdraw;

            drawAction.Cards = drawAction.Player.Deck.Draw(drawCount);
            drawAction.Player.Hand.AddRange(drawAction.Cards);

            int[] cardIndices = new int[drawAction.Cards.Count];
            for (int i = 0; i < drawAction.Cards.Count; i++)
            {
                cardIndices[i] = drawAction.Cards[i].Id;
            }

            byte targetPlayerIndex = drawAction.Player.Index;
            var  raiseEventoptions = new Photon.Realtime.RaiseEventOptions {
                Receivers = Photon.Realtime.ReceiverGroup.Others
            };
            var sendOptions = new SendOptions {
                Reliability = true
            };

            PhotonNetwork.RaiseEvent(EventCodes.OnCardsDraw, new object[] { targetPlayerIndex, drawAction.Player.Deck.Count, cardIndices }, raiseEventoptions, sendOptions);
        }
Beispiel #5
0
        private void OnPerformFatigue(object sender, object args)
        {
            var fatigueAction = args as FatigueAction;

            fatigueAction.Player.Fatigue++;

            var target       = fatigueAction.Player.Hero as IDestructable;
            var damageAction = new DamageAction(target, fatigueAction.Player.Fatigue);

            Container.AddReaction(damageAction);

            var raiseEventoptions = new Photon.Realtime.RaiseEventOptions {
                Receivers = Photon.Realtime.ReceiverGroup.Others
            };
            var sendOptions = new SendOptions {
                Reliability = true
            };

            PhotonNetwork.RaiseEvent(EventCodes.OnFatigue, fatigueAction.Player.Fatigue, raiseEventoptions, sendOptions);
        }
Beispiel #6
0
        private void OnPerformOverdraw(object sender, object args)
        {
            var overdrawAction = args as OverdrawAction;

            overdrawAction.Cards = overdrawAction.Player.Deck.Draw(overdrawAction.Amount);
            overdrawAction.Player.Graveyard.AddRange(overdrawAction.Cards);

            int[] cardIndices = new int[overdrawAction.Cards.Count];
            for (int i = 0; i < overdrawAction.Cards.Count; i++)
            {
                cardIndices[i] = overdrawAction.Cards[i].Id;
            }

            byte targetPlayerIndex = overdrawAction.Player.Index;
            var  raiseEventoptions = new Photon.Realtime.RaiseEventOptions {
                Receivers = Photon.Realtime.ReceiverGroup.Others
            };
            var sendOptions = new SendOptions {
                Reliability = true
            };

            PhotonNetwork.RaiseEvent(EventCodes.OnOverdraw, new object[] { targetPlayerIndex, overdrawAction.Player.Deck.Count, cardIndices }, raiseEventoptions, sendOptions);
        }
Beispiel #7
0
        IEnumerator SetBoard()
        {
            fadeCount = 0;
            for (int i = tileSet.Count - 1; i > 0; i--)
            {
                int        j    = Random.Range(0, i + 1);
                Vector2Int temp = tileSet[i];
                tileSet[i] = tileSet[j];
                tileSet[j] = temp;
            }
            int index = 0;

            while (index < tileSet.Count)
            {
                for (int i = index; i < Mathf.Min(index + tileSet.Count / boardWidth, tileSet.Count); i++)
                {
                    StartCoroutine(FadeInTile(tileSet[i][0], tileSet[i][1]));
                }
                index += tileSet.Count / boardWidth;
                yield return(new WaitForSeconds(0.05f));
            }
            while (fadeCount < tileSet.Count)
            {
                yield return(null);
            }
            HashSet <Vector2Int> resources = resource.GetResourceTiles();
            List <Vector2Int>    remove    = new List <Vector2Int>();

            foreach (Vector2Int r in resources)
            {
                if (boardState.ContainsNode(r[0], r[1]))
                {
                    Tile  currTile  = boardState.GetNodeTile(r[0], r[1]);
                    Color baseColor = currTile.GetBaseColor();
                    float lerpRate  = 0.2f;
                    while (lerpRate > 0.0f)
                    {
                        lerpRate -= Time.deltaTime;
                        Color lerpedColor = Color.Lerp(baseColor, Color.white * 2, 1.0f - (lerpRate / 0.2f));
                        currTile.gameObject.GetComponent <MeshRenderer>().material.SetColor("_BaseColor", lerpedColor);
                        yield return(null);
                    }
                }
                else
                {
                    remove.Add(r);
                }
            }
            foreach (Vector2Int r in remove)
            {
                resource.RemoveResourceTile(r[0], r[1]);
            }
            if (numPlayers == 2)
            {
                StartCoroutine(SetBase(baseOffset, boardWidth - baseOffset - 1, 0));
                StartCoroutine(SetBase(boardWidth - baseOffset - 1, baseOffset, 1));
            }
            else if (numPlayers == 3)
            {
                Vector2Int curr   = new Vector2Int(boardWidth - 1, baseOffset);
                Vector2Int center = new Vector2Int(boardWidth - 1, boardWidth - 1);
                StartCoroutine(SetBase(curr[0], curr[1], 0));
                for (int i = 1; i < numPlayers; i++)
                {
                    curr = Rotate120(curr, center);
                    StartCoroutine(SetBase(curr[0], curr[1], i));
                }
            }
            else if (numPlayers == 6)
            {
                Vector2Int curr   = new Vector2Int(boardWidth - 1, baseOffset);
                Vector2Int center = new Vector2Int(boardWidth - 1, boardWidth - 1);
                StartCoroutine(SetBase(curr[0], curr[1], 0));
                for (int i = 1; i < numPlayers; i++)
                {
                    curr = Rotate60(curr, center);
                    StartCoroutine(SetBase(curr[0], curr[1], i));
                }
            }
            else if (numPlayers == 1)
            {
                StartCoroutine(SetBase(baseOffset, boardWidth - baseOffset - 1, 0));
            }

            byte evCode = 0;

            Photon.Realtime.RaiseEventOptions raiseEventOptions = new Photon.Realtime.RaiseEventOptions {
                Receivers = Photon.Realtime.ReceiverGroup.MasterClient
            };
            ExitGames.Client.Photon.SendOptions sendOptions = new ExitGames.Client.Photon.SendOptions {
                Reliability = true
            };
            PhotonNetwork.RaiseEvent(evCode, null, raiseEventOptions, sendOptions);
        }