Example #1
0
        public void MessageReceived(Message message)
        {
            switch (message.MessageType)
            {
            case SyncUserListMessage.MESSAGE_TYPE: {
                var msg = (SyncUserListMessage)message;
                for (int i = 0; i < msg.usersID.Length; ++i)
                {
                    int userID      = IdentificationConverter.GetID(msg.usersID[i]);
                    int characterID = IdentificationConverter.GetID(msg.charactersID[i]);
                    var user        = new User(userID, msg.usersInfo[i], characterID);
                    _users.Add(user);
                }
                int clientUserID = IdentificationConverter.GetID(msg.clientUserID);
                _self = _users[clientUserID];
            }
            break;

            case UserOnlineMessage.MESSAGE_TYPE: {
            }
            break;

            case UserOfflineMessage.MESSAGE_TYPE: {
            }
            break;

            case UserLoadingMessage.MESSAGE_TYPE: {
            }
            break;

            case UserLoadCompleteMessage.MESSAGE_TYPE: {
            }
            break;

            case ReloadAssetsMessage.MESSAGE_TYPE: {
            }
            break;
            }
        }
Example #2
0
        public override void MessageReceived(Message message)
        {
            try {
                switch (message.MessageType)
                {
                case StorySceneResetMessage.MESSAGE_TYPE: {
                    _investigating = false;
                    _talker1       = _talker2 = null;
                    _controller.DisableTextInput();
                    _controller.HideSelections();
                    _controller.ClearDialog();
                    _controller.FinishNonRepeatAnimations();
                    _controller.FinishRepeatAnimations();
                    _controller.ClearObjectTouchListeners();
                    _controller.ClearObjects();
                    _controller.DisableInvestigationView();
                }
                break;

                case StorySceneCreateObjectMessage.MESSAGE_TYPE: {
                    var msg       = (StorySceneCreateObjectMessage)message;
                    var character = CharacterManager.Instance.FindCharacter(IdentificationConverter.GetID(msg.objID));
                    int id        = IdentificationConverter.GetID(msg.objID);
                    var sceneObj  = new SceneObject(id, character, msg.portrait);
                    _objectList.Add(sceneObj);
                    _controller.AddObject(id, msg.portrait.sprites);
                }
                break;

                case StorySceneDestroyObjectMessage.MESSAGE_TYPE: {
                    var msg = (StorySceneDestroyObjectMessage)message;
                    int id  = IdentificationConverter.GetID(msg.objID);
                    _objectList.Remove(id);
                    _controller.RemoveObject(id);
                }
                break;

                case StorySceneUpdateObjectDataMessage.MESSAGE_TYPE: {
                    var msg = (StorySceneUpdateObjectDataMessage)message;
                    int id  = IdentificationConverter.GetID(msg.objID);
                    _objectList[id].Interactable = msg.interactable;
                    if (_investigating)
                    {
                        if (msg.interactable)
                        {
                            _controller.SetObjectTouchListener(id, this.InteractWithObject);
                        }
                        else
                        {
                            _controller.SetObjectTouchListener(id, null);
                        }
                    }
                }
                break;

                case StorySceneExecuteAnimCommandsMessage.MESSAGE_TYPE: {
                    var msg           = (StorySceneExecuteAnimCommandsMessage)message;
                    var idList        = new List <int>();
                    var animList      = new List <Animation>();
                    int cameraAnimIdx = -1;
                    for (int i = 0; i < msg.objectsID.Length; ++i)
                    {
                        int id = IdentificationConverter.GetID(msg.objectsID[i]);
                        if (id == -1)
                        {
                            cameraAnimIdx = i;
                        }
                        else
                        {
                            idList.Add(id);
                            animList.Add(msg.animations[i]);
                        }
                    }
                    int[]       ids        = idList.ToArray();
                    Animation[] animations = animList.ToArray();
                    if (cameraAnimIdx != -1)
                    {
                        _controller.ExecuteAnimations(msg.animations[cameraAnimIdx], ids, animations);
                    }
                    else
                    {
                        _controller.ExecuteAnimations(ids, animations);
                    }
                }
                break;

                case StorySceneFinishNonRepeatAnimsMessage.MESSAGE_TYPE: {
                    _controller.FinishNonRepeatAnimations();
                }
                break;

                case StorySceneFinishRepeatAnimsMessage.MESSAGE_TYPE: {
                    _controller.FinishRepeatAnimations();
                }
                break;

                case StorySceneEnterStoryModeMessage.MESSAGE_TYPE: {
                    _investigating = false;
                    _talker1       = null;
                    _talker2       = null;
                    _controller.DisableInvestigationView();
                    _controller.DisableTextInput();
                    _controller.ClearObjectTouchListeners();
                }
                break;

                case StorySceneEnterTalkModeMessage.MESSAGE_TYPE: {
                    var msg = (StorySceneEnterTalkModeMessage)message;
                    _talker1          = CharacterManager.Instance.FindCharacter(IdentificationConverter.GetID(msg.talkCharacter1));
                    _talker2          = CharacterManager.Instance.FindCharacter(IdentificationConverter.GetID(msg.talkCharacter2));
                    _isTalker1Talking = msg.chara1Start;
                    _controller.DisableInvestigationView();
                    if ((_isTalker1Talking && _talker1.Controller == GameServerProxy.Instance.Self) ||
                        (!_isTalker1Talking && _talker2.Controller == GameServerProxy.Instance.Self))
                    {
                        _controller.EnabledTextInput();
                    }
                    else
                    {
                        _controller.DisableTextInput();
                    }
                    _controller.ClearObjectTouchListeners();
                }
                break;

                case StorySceneTurnTalkMessage.MESSAGE_TYPE: {
                    _isTalker1Talking = !_isTalker1Talking;
                    if ((_isTalker1Talking && _talker1.Controller == GameServerProxy.Instance.Self) ||
                        (!_isTalker1Talking && _talker2.Controller == GameServerProxy.Instance.Self))
                    {
                        _controller.EnabledTextInput();
                    }
                    else
                    {
                        _controller.DisableTextInput();
                    }
                }
                break;

                case StorySceneEnterInvestigationModeMessage.MESSAGE_TYPE: {
                    var msg    = (StorySceneEnterInvestigationModeMessage)message;
                    var userID = IdentificationConverter.GetID(msg.investigatingPlayer);
                    if (userID == GameServerProxy.Instance.Self.ID)
                    {
                        _investigating = true;
                        _controller.EnabledInvestigationView();
                    }
                    else
                    {
                        _investigating = false;
                        _controller.DisableInvestigationView();
                    }
                    foreach (var obj in _objectList)
                    {
                        if (obj.Interactable)
                        {
                            _controller.SetObjectTouchListener(obj.ID, this.InteractWithObject);
                        }
                    }
                }
                break;

                case StorySceneShowSelectionsMessage.MESSAGE_TYPE: {
                    var msg = (StorySceneShowSelectionsMessage)message;
                    _selectionShowed = true;
                    _controller.ShowSelections(msg.selections);
                }
                break;

                case StorySceneHideSelectionsMessage.MESSAGE_TYPE: {
                    _selectionShowed = false;
                    _controller.HideSelections();
                }
                break;

                case StorySceneShowSelectionVoterMessage.MESSAGE_TYPE: {
                    var msg   = (StorySceneShowSelectionVoterMessage)message;
                    var voter = GameServerProxy.Instance.FindUser(IdentificationConverter.GetID(msg.voterID));
                    _controller.SetSelectionVoter(msg.selectionIndex, voter);
                }
                break;

                case StorySceneUpdateDialogMessage.MESSAGE_TYPE: {
                    var msg   = (StorySceneUpdateDialogMessage)message;
                    int objID = IdentificationConverter.GetID(msg.portraitObjectID);
                    _controller.SetDialogPortrait(objID);
                    _controller.SetDialogText(msg.text, msg.isPrivate ? new Vec3(0.6f, 0.6f, 0.6f) : new Vec3(1.0f, 1.0f, 1.0f));
                }
                break;
                }
            } catch (System.Exception e) {
                Logger.WriteLine(e.Message);
            }
        }
Example #3
0
        public override void MessageReceived(Message message)
        {
            switch (message.MessageType)
            {
            case SyncAbilityTypeListMessage.MESSAGE_TYPE: {
                var msg = (SyncAbilityTypeListMessage)message;
                AbilityType.AbilityTypes.Clear();
                foreach (var typeInfo in msg.abilityTypes)
                {
                    var abilityType = new AbilityType(IdentificationConverter.GetID(typeInfo.id), typeInfo.name);
                    AbilityType.AbilityTypes.Add(abilityType.ID, abilityType);
                }
            }
            break;

            case CreateCharacterMessage.MESSAGE_TYPE: {
                var msg       = (CreateCharacterMessage)message;
                var pool      = CharacterManager.Instance.CharacterPool;
                var character = new Character(IdentificationConverter.GetID(msg.id), msg.avatar);
                character.Name        = msg.description.name;
                character.Description = msg.description.text;
                pool.Add(character);
            }
            break;

            case CreateTemporaryCharacterMessage.MESSAGE_TYPE: {
                var msg       = (CreateTemporaryCharacterMessage)message;
                var pool      = CharacterManager.Instance.TemporaryCharacterPool;
                var character = new Character(IdentificationConverter.GetID(msg.id), msg.avatar);
                character.Name        = msg.description.name;
                character.Description = msg.description.text;
                pool.Add(character);
            }
            break;

            case ClearTemporaryCharacterListMessage.MESSAGE_TYPE: {
                CharacterManager.Instance.TemporaryCharacterPool.Clear();
            }
            break;

            case UpdateCharacterBaseDataMessage.MESSAGE_TYPE: {
                var msg         = (UpdateCharacterBaseDataMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                character.Destroyed         = msg.destroyed;
                character.Token             = msg.token;
                character.FatePoint         = msg.fatePoint;
                character.RefreshPoint      = msg.refreshPoint;
                character.PhysicsStress     = msg.physicsStress;
                character.PhysicsStressMax  = msg.physicsStressMax;
                character.PhysicsInvincible = msg.physicsInvincible;
                character.MentalStress      = msg.mentalStress;
                character.MentalStressMax   = msg.mentalStressMax;
                character.MentalInvincible  = msg.mentalInvincible;
            }
            break;

            case UpdateCharacterAbilityDataMessage.MESSAGE_TYPE: {
                var msg         = (UpdateCharacterAbilityDataMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                var abilityType = AbilityType.AbilityTypes[IdentificationConverter.GetID(msg.typeID)];
                character.Abilities[abilityType] = new AbilityData()
                {
                    customName   = msg.customName,
                    level        = msg.level,
                    damageMental = msg.damageMental
                };
            }
            break;

            case CharacterAddAspectMessage.MESSAGE_TYPE: {
                var msg         = (CharacterAddAspectMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                var aspect      = new Aspect(IdentificationConverter.GetID(msg.aspectID));
                aspect.Name        = msg.description.name;
                aspect.Description = msg.description.text;
                character.Aspects.Add(aspect);
            }
            break;

            case CharacterRemoveAspectMessage.MESSAGE_TYPE: {
                var msg         = (CharacterRemoveAspectMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                character.Aspects.Remove(IdentificationConverter.GetID(msg.aspectID));
            }
            break;

            case CharacterUpdateAspectDataMessage.MESSAGE_TYPE: {
                var msg         = (CharacterUpdateAspectDataMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                var aspect      = character.Aspects[IdentificationConverter.GetID(msg.aspectID)];
                aspect.PersistenceType = msg.persistenceType;
                int benefiterID = IdentificationConverter.GetID(msg.benefiterID);
                if (benefiterID == -1)
                {
                    aspect.Benefiter = null;
                }
                else
                {
                    aspect.Benefiter = CharacterManager.Instance.FindCharacter(benefiterID);
                }
                aspect.BenefitTimes = msg.benefitTimes;
            }
            break;

            case CharacterClearAspectListMessage.MESSAGE_TYPE: {
                var msg         = (CharacterClearAspectListMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                character.Aspects.Clear();
            }
            break;

            case CharacterAddConsequenceMessage.MESSAGE_TYPE: {
                var msg         = (CharacterAddConsequenceMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                var consequence = new Consequence(IdentificationConverter.GetID(msg.consequenceID));
                consequence.Name        = msg.description.name;
                consequence.Description = msg.description.text;
                character.Consequences.Add(consequence);
            }
            break;

            case CharacterRemoveConsequenceMessage.MESSAGE_TYPE: {
                var msg         = (CharacterRemoveConsequenceMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                character.Consequences.Remove(IdentificationConverter.GetID(msg.consequenceID));
            }
            break;

            case CharacterUpdateConsequenceMessage.MESSAGE_TYPE: {
                var msg         = (CharacterUpdateConsequenceMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                var consequence = character.Consequences[IdentificationConverter.GetID(msg.consequenceID)];
                consequence.PersistenceType = msg.persistenceType;
                int benefiterID = IdentificationConverter.GetID(msg.benefiterID);
                if (benefiterID == -1)
                {
                    consequence.Benefiter = null;
                }
                else
                {
                    consequence.Benefiter = CharacterManager.Instance.FindCharacter(benefiterID);
                }
                consequence.BenefitTimes    = msg.benefitTimes;
                consequence.CounteractLevel = msg.counteractLevel;
                consequence.ActualDamage    = msg.actualDamage;
                consequence.Mental          = msg.mental;
            }
            break;

            case CharacterClearConsequenceListMessage.MESSAGE_TYPE: {
                var msg         = (CharacterClearConsequenceListMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                character.Consequences.Clear();
            }
            break;

            case CharacterAddStuntMessage.MESSAGE_TYPE: {
                var msg         = (CharacterAddStuntMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                var stunt       = new Stunt(IdentificationConverter.GetID(msg.stuntID));
                stunt.Name        = msg.description.name;
                stunt.Description = msg.description.text;
                character.Stunts.Add(stunt);
            }
            break;

            case CharacterRemoveStuntMessage.MESSAGE_TYPE: {
                var msg         = (CharacterRemoveStuntMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                character.Stunts.Remove(IdentificationConverter.GetID(msg.stuntID));
            }
            break;

            case CharacterUpdateStuntMessage.MESSAGE_TYPE: {
                var msg         = (CharacterUpdateStuntMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                var stunt       = character.Stunts[IdentificationConverter.GetID(msg.stuntID)];
                ///////////////////////////////////
            }
            break;

            case CharacterClearStuntListMessage.MESSAGE_TYPE: {
                var msg         = (CharacterClearStuntListMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                character.Stunts.Clear();
            }
            break;

            case CharacterAddExtraMessage.MESSAGE_TYPE: {
                var msg         = (CharacterAddExtraMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                int itemID      = IdentificationConverter.GetID(msg.boundCharacterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                var item        = CharacterManager.Instance.FindCharacter(itemID);
                var extra       = new Extra(IdentificationConverter.GetID(msg.extraID), item);
                extra.Name        = msg.description.name;
                extra.Description = msg.description.text;
                character.Extras.Add(extra);
            }
            break;

            case CharacterRemoveExtraMessage.MESSAGE_TYPE: {
                var msg         = (CharacterRemoveExtraMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                character.Extras.Remove(IdentificationConverter.GetID(msg.extraID));
            }
            break;

            case CharacterUpdateExtraMessage.MESSAGE_TYPE: {
                var msg         = (CharacterUpdateExtraMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                var extra       = character.Extras[IdentificationConverter.GetID(msg.extraID)];
                extra.IsLongRangeWeapon = msg.isLongRangeWeapon;
                extra.IsVehicle         = msg.isVehicle;
            }
            break;

            case CharacterClearExtraListMessage.MESSAGE_TYPE: {
                var msg         = (CharacterClearExtraListMessage)message;
                int characterID = IdentificationConverter.GetID(msg.characterID);
                var character   = CharacterManager.Instance.FindCharacter(characterID);
                character.Extras.Clear();
            }
            break;
            }
        }