Exemplo n.º 1
0
        //Permette di aggiungere degli eventi ad esempio quando si connette un nuovo giocatore o quando si devono cambiare le sue relative stats
        public void OnEvent(EventData photonEvent)
        {
            if (photonEvent.Code >= 200)
            {
                return;                         // >= 200 perchè è di default così
            }
            EventCodes e = (EventCodes)photonEvent.Code;

            object[] o = (object[])photonEvent.CustomData;

            switch (e)
            {
            case EventCodes.NewPlayer:
                NewPlayer_R(o);
                break;

            case EventCodes.UpdatePlayers:
                UpdatePlayers_R(o);
                break;

            case EventCodes.ChangeStat:
                ChangeStat_R(o);
                break;

            case EventCodes.RefreshTimer:
                RefreshTimer_R(o);
                break;
            }
        }
Exemplo n.º 2
0
    public void OnEvent(EventData photonEvent)
    {
        if (photonEvent.Code >= 200)
        {
            return;
        }

        EventCodes e = (EventCodes)photonEvent.Code;

        object[] o = (object[])photonEvent.CustomData;
        switch (e)
        {
        case EventCodes.NewPlayer:

            NewPlayer_R(o);
            OnEnable();
            break;

        case EventCodes.UpdatePlayers:
            UpdatePlayers_R(o);
            OnEnable();
            break;

        case EventCodes.ChangeStat:
            ChangeStat_R(o);
            OnEnable();
            break;

        case EventCodes.NewMatch:
            NewMatch_R();
            OnEnable();
            break;
        }
    }
Exemplo n.º 3
0
    public void OnClick()
    {
        if (isSelected)
        {
            // This one was previously selected
            Disable();
        }
        else
        {
            // Another one was previously selected
            //  So disable all buttons
            foreach (CharacterSelectButton selectButton in allSelectButtons)
            {
                selectButton.Disable();
            }
            // Then reenable this one
            isSelected = true;
        }
        // Alert local and client MatchManagers that a character selection has been made
        byte eventCode = EventCodes.SelectCharacter;

        object[] content = new object[] {
            PhotonNetwork.LocalPlayer.ActorNumber,
            characterType
        };
        EventCodes.RaiseEventAll(eventCode, content);
    }
Exemplo n.º 4
0
 public void RaiseClientEvent(EventCodes eventCode)
 {
     EventReceived?.Invoke(new EventData()
     {
         Code = (byte)eventCode
     });
 }
 public bool IfIsEventToIgnore(EventCodes eventCode)
 {
     return(eventCode == EventCodes.evGuildMemberWorldUpdate ||
            eventCode == EventCodes.evPlayerGetonline ||
            eventCode == EventCodes.evevLeave ||
            eventCode == EventCodes.evOutpostReward ||
            eventCode == EventCodes.evDebugDiminishingReturnInfo ||
            eventCode == EventCodes.evKilledPlayer ||
            eventCode == EventCodes.evAccessStatus ||
            eventCode == EventCodes.evSiegeCampScheduleResult ||
            eventCode == EventCodes.evZonethroughNewZone ||
            eventCode == EventCodes.evStopsMoving ||
            eventCode == EventCodes.evLeftChatChannel ||
            eventCode == EventCodes.evMatchPlayerJoinedEvent ||
            eventCode == EventCodes.evCastHit ||
            eventCode == EventCodes.evAchievementProgressInfo ||
            eventCode == EventCodes.evUpdateFame ||
            eventCode == EventCodes.evAchievementProgressInfo ||
            eventCode == EventCodes.evActiveSpellEffectsUpdate ||
            eventCode == EventCodes.evDurabilityChanged ||
            eventCode == EventCodes.evRegenerationHealthEnergyComboChanged ||
            eventCode == EventCodes.evRegenerationHealthChanged ||
            eventCode == EventCodes.evResurrectionReply ||
            eventCode == EventCodes.evUpdateUnlockedAvatarRings ||
            eventCode == EventCodes.evAchievementProgressInfo ||
            eventCode == EventCodes.evPlaceableObjectPlaceCancel ||
            eventCode == EventCodes.evMove3 ||
            eventCode == EventCodes.evPlayerLoginOrLogOff);
 }
Exemplo n.º 6
0
        public async void OnEvent(byte code, Dictionary <byte, object> parameters)
        {
            if (!this.isInitialized)
            {
                await this.InitializeAsync();
            }
            if (code == 2)
            {
                return;
            }
            object val;

            parameters.TryGetValue(252, out val);
            if (val == null)
            {
                return;
            }
            int iCode = 0;

            if (!int.TryParse(val.ToString(), out iCode))
            {
                return;
            }
            EventCodes eventCode = (EventCodes)iCode;

            if (eventCode == EventCodes.evOtherGrabbedLoot)
            {
                this.OnLootPicked(parameters);
            }
        }
Exemplo n.º 7
0
    public void OnEvent(EventData photonEvent)
    {
        EventCodes code = (EventCodes)photonEvent.Code;

        switch (code)
        {
        case EventCodes.RequestReset:
            resetMenu.SetActive(true);
            break;

        case EventCodes.DenyReset:
            OnResetDenied();
            break;

        case EventCodes.ConfirmReset:
            //PhotonNetwork.AutomaticallySyncScene = true;
            //SceneManager.LoadScene((SceneManager.GetActiveScene().buildIndex));
            SceneManager.LoadScene((SceneManager.GetActiveScene().buildIndex));

            /*if (PhotonNetwork.IsMasterClient)
             * {
             *  SceneManager.LoadScene((SceneManager.GetActiveScene().buildIndex));
             *  //PhotonNetwork.LoadLevel(SceneManager.GetActiveScene().buildIndex);
             * }*/
            break;
        }
    }
Exemplo n.º 8
0
    public void OnClick()
    {
        // Send start game event
        byte eventCode = EventCodes.StartGame;

        EventCodes.RaiseEventAll(eventCode, null);
    }
Exemplo n.º 9
0
        public void MergeEvents(ControllerEventLogs newEvents)
        {
            if (newEvents.StartDate < StartDate)
            {
                StartDate = newEvents.StartDate;
            }

            if (newEvents.EndDate > EndDate)
            {
                EndDate = newEvents.EndDate;
            }

            var incomingEventCodes = (from s in newEvents.EventCodes
                                      select s).Distinct();

            foreach (var i in incomingEventCodes)
            {
                if (!EventCodes.Contains(i))
                {
                    EventCodes.AddRange(newEvents.EventCodes);
                }
            }

            Events.AddRange(newEvents.Events);
            Events = Events.Distinct().ToList();
            Events.Sort((x, y) => DateTime.Compare(x.Timestamp, y.Timestamp));
        }
Exemplo n.º 10
0
 protected virtual void OnLastNpcKilled()
 {
     // Parasites Win
     Debug.Log("Parasite Wins!");
     EventCodes.RaiseGameOverEvent(CharacterType.Parasite);
     PhotonNetwork.RemoveCallbackTarget(this);
 }
Exemplo n.º 11
0
    void RaiseSpawnEvent(int actorNumber, CharacterType characterType, Vector2 spawnPoint)
    {
        byte eventCode = EventCodes.AssignPlayerTypeAndSpawnPoint;

        object[] content = { actorNumber, characterType, spawnPoint };
        EventCodes.RaiseEventAll(eventCode, content);
    }
    public void OnEvent(EventData photonEvent)
    {
        if (photonEvent.Code >= 200)
        {
            return;
        }

        EventCodes evCode = (EventCodes)photonEvent.Code;

        object[] obj = (object[])photonEvent.CustomData;

        switch (evCode)
        {
        case EventCodes.NewPlayer:
            ReceiveNewPlayer(obj);
            break;

        case EventCodes.UpdatePlayers:
            ReceiveUpdatePlayers(obj);
            break;

        case EventCodes.StartMatch:
            ReceiveStartMatch();
            break;

        case EventCodes.UpdateStats:
            ReceiveUpdatedPlayerStats(obj);
            break;

        case EventCodes.UpdateKillfeed:
            ReceiveKillfeedInfo(obj);
            break;
        }
    }
Exemplo n.º 13
0
 public NoMoreNPCsWinCondition()
 {
     PhotonNetwork.AddCallbackTarget(this);
     // The original SetNpcCount event has already happened, so request
     //  the value be resent
     EventCodes.RaiseEventAll(EventCodes.RequestNpcCount, null);
 }
Exemplo n.º 14
0
    public void OnEvent(EventData photonEvent)
    {
        switch (photonEvent.Code)
        {
        case EventCodes.StartGame:
            HideMenu();
            DestroyGameOverScreen();
            RemoveHud();
            break;

        case EventCodes.AssignPlayerTypeAndSpawnPoint:
            int actorNumber = (int)EventCodes.GetEventContentAtPosition(photonEvent, 0);
            if (actorNumber == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                SetCharacterType((CharacterType)EventCodes.GetEventContentAtPosition(photonEvent, 1));
            }
            break;

        case EventCodes.GameOver:
            // Deconstruct event
            CharacterType victorType = (CharacterType)EventCodes.GetFirstEventContent(photonEvent);
            ShowGameOverScreen(victorType);
            break;

        case EventCodes.SetNpcCount:
            SetRemainingNpcCount((int)EventCodes.GetFirstEventContent(photonEvent));
            break;
        }
    }
Exemplo n.º 15
0
    void UpdateHud()
    {
        switch (characterType)
        {
        case CharacterType.Hunter:
            topRightUiText.enabled = false;
            ActivateControls(HunterControls);
            break;

        case CharacterType.Parasite:
            topRightUiText.enabled = true;
            UpdateHealthObject(ParasiteData.STARTING_HEALTH);
            ActivateControls(ParasiteControls);
            break;

        default:
            topRightUiText.enabled = false;
            break;
        }
        // Display NPC count
        GameObject npcCountObject = Instantiate(NpcCountPrefab, Vector3.zero, Quaternion.identity, canvas);

        // Draw it underneath the pause menu
        npcCountObject.transform.SetAsFirstSibling();
        npcCountObject.GetComponentInChildren <RectTransform>().anchoredPosition = new Vector2(UI_PADDING_DISTANCE, -UI_PADDING_DISTANCE);
        npcCountText = npcCountObject.GetComponentInChildren <Text>();
        // The original SetNpcCount event has likely already happened, so request
        //  the value be resent
        EventCodes.RaiseEventAll(EventCodes.RequestNpcCount, null);
    }
Exemplo n.º 16
0
    //RECIEVE EVENT
    public void OnEvent(EventData photonEvent)
    {
        if (photonEvent.Code >= 200)
        {
            return;                                    //Photon reserviert automatisch 200-255, somit koennen wir nur unter 199 benutzen, deshalb wird nachgefragt, siehe Dokumentation
        }
        EventCodes e = (EventCodes)photonEvent.Code;   //Anlass des Ausfuehrens nehmen

        object[] o = (object[])photonEvent.CustomData; //Code unwrappen

        switch (e)                                     //Handeln jeh nach Anlass
        {
        case EventCodes.NewPlayer:
            NewPlayer_R(o);     //R = Recieve (Bezogen auf das Event)
                                //Sended den Code zur passenden Event-Recieve-Methode
            break;

        case EventCodes.UpdatePlayers:
            UpdatePlayers_R(o);     //R = Recieve (Bezogen auf das Event)
                                    //Sended den Code zur passenden Event-Recieve-Methode
            break;

        case EventCodes.ChangeStat:
            ChangeStat_R(o);     //R = Recieve (Bezogen auf das Event)
                                 //Sended den Code zur passenden Event-Recieve-Methode
            break;
        }
    }
Exemplo n.º 17
0
    public void OnEvent(EventData photonEvent)
    {
        EventCodes code = (EventCodes)photonEvent.Code;

        switch (code)
        {
        case EventCodes.LooseALife:
            if (transform.childCount > 1)
            {
                Destroy(transform.GetChild(transform.childCount - 1).gameObject);
            }


            else if (transform.childCount <= 1)
            {
                GameObject.Find("GamePad").GetComponent <GamePad>().StopPad();

                RaiseEventOptions options = new RaiseEventOptions {
                    Receivers = ReceiverGroup.All
                };
                PhotonNetwork.RaiseEvent((byte)EventCodes.PlayerDead, 0, options, SendOptions.SendReliable);
            }
            break;
        }
    }
Exemplo n.º 18
0
 /// <summary>
 /// Using the EventDataItem structure allows us to ensure that the log line contains
 /// all we need for the Activity report. see the ActivityServiceTest for
 /// an indiction of the format - :: features heavily
 /// </summary>
 /// <param name="eventCode">used by the activity report</param>
 /// <param name="url">s/be null if no valid url is availble otherwise it is typically
 /// a permalink for a blog post.
 /// Sorry this can't be a string - but too many strings allows for errors in building events</param>
 /// <param name="userMessage"> a template with placeholders for other parameters, e.g.
 /// "{email} has logged in"</param>
 /// <param name="params">in the above example there should be one element - the email of the logger in</param>
 public EventDataItem(EventCodes eventCode, Uri url, string userMessage
                      , params object[] @params)
 {
     this.eventCode   = eventCode;
     this.url         = url?.ToString();
     this.userMessage = userMessage;
     this.@params     = @params;
 }
Exemplo n.º 19
0
        public void OnEvent(byte code, Dictionary <byte, object> parameters)
        {
            if (code == 2)
            {
                return;
            }
            object val;

            parameters.TryGetValue(252, out val);
            if (val == null)
            {
                return;
            }
            int iCode = 0;

            if (!int.TryParse(val.ToString(), out iCode))
            {
                return;
            }

            EventCodes eventCode    = (EventCodes)iCode;
            string     eventCodeStr = eventCode.ToString();

            if (triggeredEvents.ContainsKey(eventCodeStr))
            {
                triggeredEvents[eventCodeStr] += 1;
            }
            else
            {
                triggeredEvents[eventCodeStr] = 1;
            }

            /*if (eventCode.ToString().StartsWith("Cast") || eventCode.ToString().StartsWith("Attack") || eventCode.ToString().StartsWith("Health")
            || eventCode.ToString().Contains("Spell") || eventCode.ToString().Contains("Mount") || eventCode.ToString().Contains("Energy")
            || eventCode.ToString().Contains("Guild") || eventCode.ToString().Contains("Harvest") || eventCode.ToString().Contains("Channeling"))
            || {
            ||  return;
            || }*/

            string loggerName = "Event." + eventCode.ToString();
            ILog   log        = LogManager.GetLogger(loggerName);

            log.Debug(parameters);
            if (_eventHandlers.ContainsKey(eventCode))
            {
                foreach (HandleEvent eventHandler in _eventHandlers[eventCode])
                {
                    try
                    {
                        eventHandler(parameters, log);
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                    }
                }
            }
        }
Exemplo n.º 20
0
        public EventDataItem( EventCodes eventCode, string userMessage, string localUrl )
        {
			// http://www.net-security.org/vuln.php?id=3680
			localUrl = LogEncoder.Encode(localUrl);

            EventTimeUtc = DateTime.Now.ToUniversalTime();
            HtmlMessage = EventMessageTemplates.FormatMessage( eventCode, userMessage, localUrl );
            EventCode = Convert.ToInt32(eventCode);
        }
Exemplo n.º 21
0
        public EventDataItem(EventCodes eventCode, string userMessage, string localUrl)
        {
            // http://www.net-security.org/vuln.php?id=3680
            localUrl = LogEncoder.Encode(localUrl);

            EventTimeUtc = DateTime.Now.ToUniversalTime();
            HtmlMessage  = EventMessageTemplates.FormatMessage(eventCode, userMessage, localUrl);
            EventCode    = Convert.ToInt32(eventCode);
        }
Exemplo n.º 22
0
    public void SetReady()
    {
        // Construct event
        bool isReady   = toggle.isOn;
        byte eventCode = EventCodes.SetReady;

        object[] content = new object[] { PhotonNetwork.LocalPlayer.ActorNumber, isReady };
        EventCodes.RaiseEventAll(eventCode, content);
    }
Exemplo n.º 23
0
        public async void OnEvent(byte code, Dictionary <byte, object> parameters)
        {
            if (!this.isInitialized)
            {
                await this.InitializeAsync();
            }
            if (code == 2)
            {
                return;
            }
            object val;

            parameters.TryGetValue(252, out val);

            if (val == null)
            {
                return;
            }
            int iCode = 0;

            if (!int.TryParse(val.ToString(), out iCode))
            {
                return;
            }
            EventCodes eventCode = (EventCodes)iCode;

            Debug.WriteLine(eventCode);

            /* foreach (var entry in parameters)
             * {
             *
             *   Debug.WriteLine(entry.Value);
             *
             *   Type valueType = entry.Value.GetType();
             *   if (valueType.IsArray) {
             *       foreach (var item in (Array)entry.Value)
             *       {
             *           Debug.WriteLine(item.ToString());
             *       }
             *   }
             *
             * }*/


            if (eventCode == EventCodes.evOtherGrabbedLoot)
            {
                this.OnLootPicked(parameters);
            }

            if (eventCode == EventCodes.evNewCharacter)
            {
                this.OnLootPlayerIsland(parameters);
            }
        }
Exemplo n.º 24
0
 public void OnEvent(EventData photonEvent)
 {
     if (photonEvent.Code == EventCodes.RequestNpcCount)
     {
         if (PhotonNetwork.IsMasterClient)
         {
             // Resend the current NPC count
             object[] content = { NpcList.Count };
             EventCodes.RaiseEventAll(EventCodes.SetNpcCount, content);
         }
     }
 }
Exemplo n.º 25
0
    //listen to photon events
    public void OnEvent(EventData photonEvent)
    {
        EventCodes code = (EventCodes)photonEvent.Code;

        switch (code)
        {
        case EventCodes.PlayerStartedShooting:
            if ((int)photonEvent.CustomData == photonView.OwnerActorNr)
            {
                Debug.Log("Start shooting actor " + photonView.OwnerActorNr);
                isShooting = true;
            }
            break;

        case EventCodes.PlayerStoppedShooting:
            if ((int)photonEvent.CustomData == photonView.OwnerActorNr)
            {
                Debug.Log("Stop shooting actor " + photonView.OwnerActorNr);
                isShooting = false;
            }
            break;

        //End the game on player death
        case EventCodes.PlayerDead:
            GameObject.Find("GamePad").GetComponent <GamePad>().StopPad();
            SceneManager.LoadScene("GameOver");
            break;


        case EventCodes.HelperSpawned:
            if ((int)photonEvent.CustomData == photonView.OwnerActorNr)
            {
                StartHelper();
            }
            break;

        case EventCodes.HelperDespawned:
            if ((int)photonEvent.CustomData == photonView.OwnerActorNr)
            {
                //restart counting the bullets until the next helper spawn
                bulletCountForHelper = 0;
            }
            break;

        case EventCodes.PlayerInvincibleStart:
            if ((int)photonEvent.CustomData == photonView.OwnerActorNr)
            {
                StartCoroutine("InvincibilityTimer");
            }
            break;
        }
    }
        private static string GetMessageTemplate(EventCodes code)
        {
            string template = messages[code] as string;

            if (template == null)
            {
                return("Message template not found");
            }
            else
            {
                return(template);
            }
        }
Exemplo n.º 27
0
        public async Task Instrument(Func <Task> aspect, string instrumentorName)
        {
            var instrumentation = new Instrumentation(instrumentorName);

            instrumentation.Stopwatch.Start();

            await aspect();

            instrumentation.Stopwatch.Stop();

            _logger.Write(LogLevel.Information,
                          $"{EventCodes.EventInstrumented(instrumentation.Name)} - Time taken: {instrumentation.Stopwatch.Elapsed}");
        }
Exemplo n.º 28
0
    public void OnEvent(EventData photonEvent)
    {
        Debug.Log("Photon Event received");
        EventCodes code = (EventCodes)photonEvent.Code;

        switch (code)
        {
        case EventCodes.LevelCompleted:
            Debug.Log("Level completed");
            StartCoroutine(OnLevelCompleted());
            break;
        }
    }
Exemplo n.º 29
0
    public void RaiseNetworkEvent(EventCodes eventCode, object[] ctx, ReceiverGroup recievers = ReceiverGroup.All)
    {
        RaiseEventOptions eventOpt = new RaiseEventOptions()
        {
            Receivers = recievers
        };
        SendOptions sendOpt = new SendOptions()
        {
            Reliability = true
        };

        PhotonNetwork.RaiseEvent((byte)eventCode, ctx, eventOpt, sendOpt);
    }
Exemplo n.º 30
0
 public void Initialize(string xml)
 {
     if (String.IsNullOrWhiteSpace(xml))
     {
         return;
     }
     if (EventCodes.Count != 0 && LastKnownChatCodesXml == xml)
     {
         return;
     }
     EventCodes.Clear();
     LastKnownChatCodesXml = xml;
     LoadCodes(XElement.Parse(xml));
 }
Exemplo n.º 31
0
    //react to photon events
    public virtual void OnEvent(EventData photonEvent)
    {
        EventCodes code = (EventCodes)photonEvent.Code;

        switch (code)
        {
        case EventCodes.SpawnableDespawned:     //Caused, when spawnable has despawned on any other client
            var vec = (Vector2)photonEvent.CustomData;
            if (targetLocation.x == vec.x && targetLocation.y == vec.y)
            {
                Despawn();
            }
            break;
        }
    }
Exemplo n.º 32
0
 protected static void CheckDefaultEventParams(EventReceivedEventArgs eventArgs, EventCodes eventCode, int actorNumber)
 {
     CheckEventParam(eventArgs, ParameterKeys.Code, (byte)eventCode);
     CheckEventParam(eventArgs, ParameterKeys.ActorNr, actorNumber);
 }
Exemplo n.º 33
0
 public PacketError(EventCodes ECode)
     : base(ECode)
 {
 }
Exemplo n.º 34
0
 public LoginEvent(EventCodes ECode)
     : base(ECode)
 {
 }
Exemplo n.º 35
0
 public NetworkEvent(EventCodes ECode)
     : base(ECode)
 {
 }
Exemplo n.º 36
0
 public ProgressEvent(EventCodes ECode)
     : base(ECode)
 {
 }
Exemplo n.º 37
0
 public TransactionEvent(EventCodes ECode)
     : base(ECode)
 {
 }
Exemplo n.º 38
0
 public EventObject(EventCodes Code)
 {
     ECode = Code;
 }
Exemplo n.º 39
0
 private static string GetMessageTemplate(EventCodes code)
 {
     string template = messages[code] as string;
     if ( template == null )
     {
         return "Message template not found";
     }
     else
     {
         return template;
     }
 }
Exemplo n.º 40
0
 public static string FormatMessage( EventCodes eventCode, string userMessage, string localUrl )
 {
     return String.Format( GetMessageTemplate( eventCode ), eventCode, userMessage, localUrl, null, null );
 }
Exemplo n.º 41
0
 public CityTransitionEvent(EventCodes ECode)
     : base(ECode)
 {
 }
Exemplo n.º 42
0
        public static string FormatMessage( EventCodes eventCode, string userMessage, string localUrl, string remoteUrl )
        {
			string clippedUrl = ClipString(remoteUrl);
            return String.Format( GetMessageTemplate( eventCode ), eventCode, userMessage, localUrl, remoteUrl, clippedUrl );
        }