コード例 #1
0
    //캐릭터 움직임(공격, 점프, 스킬 등등) -> Client
    public void CharacterActionSend(int action)
    {
        if (characterManager == null)
        {
            characterManager = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterManager>();
        }

        CharacterActionData   characterActionData   = new CharacterActionData(action, (byte)characterManager.UserNum);
        CharacterActionPacket characterActionPacket = new CharacterActionPacket(characterActionData);

        characterActionPacket.SetPacketId((int)P2PPacketId.CharacterAction);

        byte[] msg = CreatePacket(characterActionPacket);

        Debug.Log("캐릭터 상태 보냄");

        for (int index = 0; index < networkManager.UserIndex.Count; index++)
        {
            int userIndex = networkManager.UserIndex[index].UserNum;

            if (networkManager.MyIndex != userIndex)
            {
                DataPacket packet = new DataPacket(CreateUdpPacket(characterActionPacket, udpId[userIndex]), networkManager.UserIndex[index].EndPoint);
                sendMsgs.Enqueue(packet);
            }
        }
    }
コード例 #2
0
    public CharacterAction(CharacterActionData data, float playback_time, Character self, Transform main_target, bool is_lighting, float scale)
    {
        this.Data = data;
        this.self = self;
//         this.target_container = target_container;
//         if (target_container != null)
//             this.target = target_container.Creature;
        StartTime = playback_time;

        m_Length           = self.PlayAnimationMove(playback_time, Data.AnimationName, main_target, new Character.MoveProperty(scale, data.Effect.MoveScale, data.Effect.FxHeight));
        IsPlayingAnimation = true;
        Data.Effect.Play(is_lighting, scale);

        if (data.CameraAnimation != null && BattleBase.Instance != null && BattleBase.Instance.m_SkillCamera != null)
        {
#if SH_ASSETBUNDLE
            BattleBase.Instance.m_SkillCamera.CheckFrame(data.CameraAnimation);
#endif

            BattleBase.Instance.SetActionMode(true, data.ActionMode, self.Creature, self.CharacterAnimation.IsMoveState(Data.AnimationName) == false);
            if (data.DelayedApply)
            {
                foreach (var hit in Data.Effect.Hit)
                {
                    hit.time = 0f;
                }
            }
            foreach (var buff in Data.Effect.Buff)
            {
                buff.time = 0f;
            }
        }
    }
コード例 #3
0
        public bool Serialize(CharacterActionData data)
        {
            bool ret = true;

            ret &= Serialize(data.action);
            ret &= Serialize(data.userNum);
            return(ret);
        }
コード例 #4
0
    //Client
    public void CharacterAction(DataPacket packet, int udpId)
    {
        CharacterActionPacket characterActionPacket = new CharacterActionPacket(packet.msg);
        CharacterActionData   characterActionData   = characterActionPacket.GetData();

        CharacterManager characterManager = dungeonManager.characters[characterActionData.userNum];

        characterManager.CharState(characterActionData.action);
    }
コード例 #5
0
ファイル: Character.cs プロジェクト: tapenjoyGame/cry
    public CharacterActionData GetAction(string action_name)
    {
        CharacterActionData action = Array.Find(Actions, a => a.AnimationName == action_name);

        if (action == null)
        {
            throw new System.Exception(string.Format("can't find action in {0} : {1}", name, action_name));
        }
        return(action);
    }
コード例 #6
0
    public CharacterAction_EffectBuff Clone(CharacterActionData action_data, ICreature skill_creature, ISkillTarget target, CharacterAction_EffectTarget linked_target)
    {
        CharacterAction_EffectBuff new_effect = new CharacterAction_EffectBuff();

        new_effect.m_ActionData            = action_data;
        new_effect.time                    = this.time;
        new_effect.action_component_prefab = this.action_component_prefab;
        new_effect.target                  = target;
        new_effect.target_linked           = target_linked;
        new_effect.LinkedTarget            = linked_target;
        new_effect.m_SkillCreature         = skill_creature;
        return(new_effect);
    }
コード例 #7
0
    public CharacterAction_EffectCasting Clone(CharacterActionData action_data, Character self)
    {
        CharacterAction_EffectCasting new_effect = new CharacterAction_EffectCasting();

        base.CloneData(action_data, new_effect);
        new_effect.AttachType = this.AttachType;
        if (action_data != null)
        {
            new_effect.target = self;
        }

        return(new_effect);
    }
コード例 #8
0
    public CharacterActionData Clone(bool forPlay, Character self, List <ISkillTarget> targets, float duration)
    {
        CharacterActionData action = new CharacterActionData();

        action.Duration        = duration;
        action.DelayedApply    = DelayedApply;
        action.AnimationName   = this.AnimationName;
        action.Effect          = this.Effect.Clone(forPlay == true?action:null, self, targets);
        action.CameraAnimation = this.CameraAnimation;
        action.ActionMode      = this.ActionMode;

        return(action);
    }
コード例 #9
0
    public CharacterAction_EffectCamera Clone(CharacterActionData action_data, ICreature skill_creature, ISkillTarget target, CharacterAction_EffectTarget linked_target)
    {
        CharacterAction_EffectCamera new_effect = new CharacterAction_EffectCamera();

        new_effect.m_ActionData    = action_data;
        new_effect.time            = this.time;
        new_effect.target          = target;
        new_effect.target_linked   = target_linked;
        new_effect.LinkedTarget    = linked_target;
        new_effect.m_SkillCreature = skill_creature;
        new_effect.power           = power;
        new_effect.duration        = duration;
        return(new_effect);
    }
コード例 #10
0
    public CharacterAction_EffectHit Clone(CharacterActionData action_data, ICreature skill_creature, ISkillTarget target, CharacterAction_EffectTarget linked_target)
    {
        CharacterAction_EffectHit new_effect = new CharacterAction_EffectHit();

        new_effect.m_ActionData            = action_data;
        new_effect.chance                  = this.chance;
        new_effect.time                    = this.time;
        new_effect.action_component_prefab = this.action_component_prefab;
        new_effect.target                  = target;
        new_effect.target_linked           = target_linked;
        new_effect.LinkedTarget            = linked_target;
        new_effect.time_tick               = this.time_tick;
        new_effect.time_gap                = this.time_gap;
        new_effect.count                   = this.count;
        new_effect.m_SkillCreature         = skill_creature;
        return(new_effect);
    }
コード例 #11
0
ファイル: Character.cs プロジェクト: tapenjoyGame/cry
    public bool PlayAction(string action_name, bool is_lighting, float move_scale, float duration)
    {
        CharacterActionData action = Array.Find(Actions, a => a.AnimationName == action_name);

        if (action != null)
        {
            AddAction(action.CreateAction(PlaybackTime, this, null, is_lighting, move_scale, duration));
        }
        else
        {
            if (m_AnimationAdoptor != null)
            {
                return(m_AnimationAdoptor.Play(action_name, PlaybackTime) != 0f);
            }
        }
        return(true);
    }
コード例 #12
0
    public CharacterAction_EffectTarget Clone(CharacterActionData action_data, Character self, Character main_target)
    {
        CharacterAction_EffectTarget new_effect = new CharacterAction_EffectTarget();

        base.CloneData(action_data, new_effect);
        if (action_data != null)
        {
            new_effect.target = main_target;
        }

        new_effect.time_tick                = time_tick;
        new_effect.count                    = count;
        new_effect.self                     = self;
        new_effect.TweenName                = this.TweenName;
        new_effect.AttachParticle           = this.AttachParticle;
        new_effect.FinishParticleAfterTween = this.FinishParticleAfterTween;

        return(new_effect);
    }
コード例 #13
0
        public bool Deserialize(ref CharacterActionData element)
        {
            if (GetDataSize() == 0)
            {
                // 데이터가 설정되지 않았다.
                return(false);
            }

            bool ret     = true;
            byte action  = 0;
            byte userNum = 0;

            ret            &= Deserialize(ref action);
            ret            &= Deserialize(ref userNum);
            element.action  = action;
            element.userNum = userNum;

            return(ret);
        }
コード例 #14
0
 public void SubmitAction(CharacterActionData data)
 {
     Emit("submitActionData", new JSONObject(JsonUtility.ToJson(data)));
 }
コード例 #15
0
    public override void OnInspectorGUI()
    {
//         base.OnInspectorGUI();

        Character          character           = (Character)target;
        CharacterAnimation character_animation = character.GetComponent <CharacterAnimation>();

        EditorGUILayout.BeginVertical();
        // debug
        if (Application.isPlaying)
        {
            s_Util.SeparatorToolbar("Debug", null);

            int selected_container = EditorPrefs.GetInt("Character_ActionTarget", 1);
            int range = EditorPrefs.GetInt("Character_ActionRange", 1);

            EditorGUILayout.BeginHorizontal();
            EditorGUIUtility.labelWidth = 70f;
            Time.timeScale = EditorGUILayout.FloatField("TimeScale", Time.timeScale, GUILayout.Width(110f));
            if (GUILayout.Button("Reset", GUILayout.Width(50f)))
            {
                Time.timeScale = 1f;
            }
            if (GUILayout.Button("Slow", GUILayout.Width(50f)))
            {
                Time.timeScale = 0.1f;
            }
            if (GUILayout.Button("Pause", GUILayout.Width(50f)))
            {
                Time.timeScale = 0f;
            }
            float new_time_skip = EditorGUILayout.FloatField("TimeSkip", time_skip, GUILayout.Width(110f));
            if (GUILayout.Button("Reset", GUILayout.Width(50f)))
            {
                new_time_skip = 0f;
            }
            if (GUILayout.Button("0.5", GUILayout.Width(50f)))
            {
                new_time_skip = 0.5f;
            }
            if (GUILayout.Button("1", GUILayout.Width(50f)))
            {
                new_time_skip = 1f;
            }
            if (time_skip != new_time_skip)
            {
                time_skip = new_time_skip;
            }
            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();

            GameObject countdown_object = null;
#if SH_ASSETBUNDLE
            if (m_Recording != RecordState.None)
            {
                GUI.backgroundColor = Color.green;
            }

            if ((GUILayout.Button("Record") && m_Recording == RecordState.None) && BattleBase.Instance.IsPause == ePauseType.None)
            {
                m_Recording = RecordState.Waiting;
//                m_Recording = RecordState.WaitingWithCamera;

                if (m_Recording == RecordState.WaitingWithCamera)
                {
                    BattleTest.Instance._capture._forceFilename = string.Format("{0}_{1}_scaled.avi", character.name, action_list.Selected.AnimationName);
                }
                else
                {
                    BattleTest.Instance._capture._forceFilename = string.Format("{0}_{1}.avi", character.name, action_list.Selected.AnimationName);
                }
                BattleTest.Instance._capture.SelectCodec(false);
                BattleTest.Instance._capture.SelectAudioDevice(false);
                // We have to queue the start capture otherwise Screen.width and height aren't correct
                BattleTest.Instance._capture.QueueStartCapture();

                BattleTest.Instance.m_Countdown.gameObject.SetActive(true);
                BattleTest.Instance.m_RecordTime.gameObject.SetActive(true);
                Debug.Log("Record Start");
            }
            GUI.backgroundColor = Color.white;
            if (m_Recording == RecordState.Waiting || m_Recording == RecordState.WaitingWithCamera)
            {
                countdown_object = BattleTest.Instance.m_Countdown.gameObject;
            }
#endif
            if ((GUILayout.Button("Play") || m_Recording == RecordState.Waiting && countdown_object.activeInHierarchy == false) && BattleBase.Instance.IsPause == ePauseType.None)
            {
                if (m_Recording == RecordState.Waiting)
                {
                    m_Recording = RecordState.Recording;
                }

                CharacterContainer action_target = containers[selected_container];

                List <CharacterContainer> target_containers = containers.Where(c => c.transform.parent.name == action_target.transform.parent.name).ToList();
                SkillTargetContainer      skill_target      = new SkillTargetContainer();
                skill_target.targets = new List <ISkillTarget>();

                skill_target.targets.Add(new SkillTargetDummy(character, action_target.Character));
                int target_index = target_containers.FindIndex(c => c == action_target);
                for (int i = 1; i < range; ++i)
                {
                    if (target_index - i >= 0)
                    {
                        skill_target.targets.Add(new SkillTargetDummy(character, target_containers[target_index - i].Character));
                    }
                    else
                    {
                        skill_target.targets.Add(null);
                    }
                    if (target_index + i < target_containers.Count)
                    {
                        skill_target.targets.Add(new SkillTargetDummy(character, target_containers[target_index + i].Character));
                    }
                    else
                    {
                        skill_target.targets.Add(null);
                    }
                }

                if (skill_target.targets != null)
                {
                    skill_target.main_target = skill_target.targets[0].Character.transform;
                    character.DoActionEditor(action_list.SelectedIndex, skill_target, false, character.Creature.Scale - 1f, SkillTargetDummy.BuffDuration);
                    if (new_time_skip > 0f)
                    {
                        character.Creature.PlaybackTime += new_time_skip;
                    }
                }
            }
            if ((GUILayout.Button("Play With Camera") || m_Recording == RecordState.WaitingWithCamera && countdown_object.activeInHierarchy == false) && BattleBase.Instance.IsPause == ePauseType.None)
            {
                if (m_Recording == RecordState.WaitingWithCamera)
                {
                    m_Recording = RecordState.Recording;
                }

                CharacterContainer action_target = containers[selected_container];

                List <CharacterContainer> target_containers = containers.Where(c => c.transform.parent.name == action_target.transform.parent.name).ToList();
                SkillTargetContainer      skill_target      = new SkillTargetContainer();
                skill_target.targets = new List <ISkillTarget>();

                skill_target.targets.Add(new SkillTargetDummy(character, action_target.Character));
                int target_index = target_containers.FindIndex(c => c == action_target);
                for (int i = 1; i < range; ++i)
                {
                    if (target_index - i >= 0)
                    {
                        skill_target.targets.Add(new SkillTargetDummy(character, target_containers[target_index - i].Character));
                    }
                    else
                    {
                        skill_target.targets.Add(null);
                    }
                    if (target_index + i < target_containers.Count)
                    {
                        skill_target.targets.Add(new SkillTargetDummy(character, target_containers[target_index + i].Character));
                    }
                    else
                    {
                        skill_target.targets.Add(null);
                    }
                }

                if (skill_target.targets != null)
                {
                    skill_target.main_target = skill_target.targets[0].Character.transform;
                    character.DoActionEditor(action_list.SelectedIndex, skill_target, true, BattleBase.LightingScaleValue, SkillTargetDummy.BuffDuration);
                    BattleBase.Instance.AddLighting(character.Creature, character.MainAction.FirstActionTime, character.MainAction.Data.Effect.ScaleTime, character.MainAction.Data.Effect.JumpScale);
                    BattleBase.Instance.AddLightingTargets(character.Creature.IsTeam, skill_target.targets, character.Creature);
                    if (new_time_skip > 0f)
                    {
                        character.Creature.PlaybackTime += new_time_skip;
                    }
                }
            }
            if (GUILayout.Button("Cancel"))
            {
                character.CancelAction(false);
            }
            EditorGUILayout.EndHorizontal();

            if (BattleBase.Instance != null)
            {
                EditorGUILayout.BeginHorizontal();
                BattleBase.Instance.tween_system.DefaultBundleIndex = EditorGUILayout.Popup("tween", BattleBase.Instance.tween_system.DefaultBundleIndex, BattleBase.Instance.tween_system.bundles.Select(b => b.Name).ToArray());
                if (GUILayout.Button("Play"))
                {
                    BattleBase.Instance.tween_system.Play(BattleBase.Instance.tween_system.DefaultBundleIndex, null, character.GetComponent <HFX_TweenSystem>(), character.transform.GetChild(0));
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginHorizontal();
            if (character.Creature != null)
            {
                eInspectorMapCreatureType scale_type = eInspectorMapCreatureType.Normal;
                if (character.Creature.Scale == 1f)
                {
                    scale_type = eInspectorMapCreatureType.Normal;
                }
                else if (character.Creature.Scale == 1.2f)
                {
                    scale_type = eInspectorMapCreatureType.Elite;
                }
                else if (character.Creature.Scale == 1.4f)
                {
                    scale_type = eInspectorMapCreatureType.Boss;
                }

                eInspectorMapCreatureType new_scale_type = (eInspectorMapCreatureType)EditorGUILayout.EnumPopup("Scale", scale_type);
                if (scale_type != new_scale_type)
                {
                    float new_scale = 1f;
                    if (new_scale_type == eInspectorMapCreatureType.Normal)
                    {
                        new_scale = 1f;
                    }
                    else if (new_scale_type == eInspectorMapCreatureType.Elite)
                    {
                        new_scale = 1.2f;
                    }
                    else if (new_scale_type == eInspectorMapCreatureType.Boss)
                    {
                        new_scale = 1.4f;
                    }

                    character.Creature.Scale       = new_scale;
                    character.transform.localScale = Vector3.one * new_scale;
                }
                character.Creature.IsDead = EditorGUILayout.Toggle("Dead", character.Creature.IsDead);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            List <string> container_names = new List <string>();
            container_names.AddRange(containers.Select(c => c.transform.parent.name + "/" + c.name));
            container_names.Add("Self");
            container_names.Add("Enemy1");
            container_names.Add("Enemy5");
            container_names.Add("Mine1");
            container_names.Add("Mine5");

            selected_container = EditorGUILayout.Popup(selected_container, container_names.ToArray());
            if (selected_container >= 0 && selected_container < container_names.Count)
            {
                switch (container_names[selected_container])
                {
                case "Self":
                    selected_container = container_names.IndexOf(character.transform.parent.parent.name + "/" + character.transform.parent.name);
                    break;

                case "Mine1":
                    selected_container = container_names.IndexOf("Mine/Character1");
                    break;

                case "Mine5":
                    selected_container = container_names.IndexOf("Mine/Character5");
                    break;

                case "Enemy1":
                    selected_container = container_names.IndexOf("Enemy/Character1");
                    break;

                case "Enemy5":
                    selected_container = container_names.IndexOf("Enemy/Character5");
                    break;
                }
            }
            EditorPrefs.SetInt("Character_ActionTarget", selected_container);

            range = EditorGUILayout.IntSlider(range, 1, 5);
            EditorPrefs.SetInt("Character_ActionRange", range);
            EditorGUILayout.EndHorizontal();

            if (character.PlayingActions.Count > 0)
            {
                foreach (var action in character.PlayingActions)
                {
                    EditorGUILayout.LabelField(string.Format("{0} - {1}", action.Name, action.Length));
                }
                EditorUtility.SetDirty((MonoBehaviour)character);
            }
#if SH_ASSETBUNDLE
            else if (m_Recording == RecordState.Recording)
            {
                m_Recording        = RecordState.Finishing;
                m_RecordFinishTime = Time.time + 3f;
                BattleTest.Instance.m_RecordTime.SetFinish();
            }

            if (m_Recording == RecordState.Finishing && Time.time > m_RecordFinishTime)
            {
                m_Recording = RecordState.None;
                BattleTest.Instance._capture.StopCapture();
                BattleTest.Instance.m_RecordTime.gameObject.SetActive(false);
                Debug.Log("Record Finished");
            }
#endif
        }

        s_Util.SeparatorToolbar("System", null);
        if (GUILayout.Button("Set Sound"))
        {
            foreach (var action in character.Actions)
            {
                string    audio_path = string.Format("Assets/Sounds/Character/{0}_{1}.wav", character.name, action.AnimationName);
                AudioClip audio      = AssetDatabase.LoadAssetAtPath(audio_path, typeof(AudioClip)) as AudioClip;
                if (audio != null)
                {
                    if (action.Effect.Casting.Length == 0 || action.Effect.Casting[0].time != 0)
                    {
                        var temp_action_list = action.Effect.Casting.ToList();
                        temp_action_list.Add(new CharacterAction_EffectCasting());
                        action.Effect.Casting = temp_action_list.ToArray();
                    }
                    if (action.Effect.Casting[0].sound_list[0].sound == null)
                    {
                        action.Effect.Casting[0].sound_list[0].sound = audio;
                        Debug.LogFormat("Set Sound : {0}", audio.name);
                    }
                }
            }
        }
        GUILayout.BeginHorizontal();
        character.m_DefaultEffect = EditorGUILayout.ObjectField("Default Effect", character.m_DefaultEffect, typeof(HFX_ParticleSystem), false) as HFX_ParticleSystem;
        if (GUILayout.Button("Add to scene", GUILayout.Width(150f)))
        {
            AddParticleSystemToScene(character, character.m_DefaultEffect, 0f);
        }
        GUILayout.EndHorizontal();

        CharacterActionData selected_action = action_list.OnInspectorGUI();

        if (selected_action != null)
        {
            selected_action.AnimationName   = CharacterAnimationInspector.OnInspectorAnimation(character_animation, selected_action.AnimationName);
            selected_action.CameraAnimation = EditorGUILayout.ObjectField("Camera Animation", selected_action.CameraAnimation, typeof(AnimationClip), false) as AnimationClip;
            if (selected_action.CameraAnimation != null)
            {
                selected_action.ActionMode   = (BattleBase.eActionMode)EditorGUILayout.EnumPopup("ActionMode", selected_action.ActionMode);
                selected_action.DelayedApply = EditorGUILayout.Toggle("Delayed Apply", selected_action.DelayedApply);
            }
            selected_action.Effect.ScaleTime       = EditorGUILayout.FloatField("Scale Time", selected_action.Effect.ScaleTime);
            selected_action.Effect.MoveScale       = EditorGUILayout.FloatField("Move Scale", selected_action.Effect.MoveScale);
            selected_action.Effect.JumpScale       = EditorGUILayout.FloatField("Jump Scale", selected_action.Effect.JumpScale);
            selected_action.Effect.FxHeight        = EditorGUILayout.FloatField("Fx Height", selected_action.Effect.FxHeight);
            selected_action.Effect.UseSingTarget   = EditorGUILayout.Toggle("Use Single Target", selected_action.Effect.UseSingTarget);
            selected_action.Effect.TargetTimeGap   = EditorGUILayout.FloatField("Time Gap", selected_action.Effect.TargetTimeGap);
            selected_action.Effect.TargetTimeGroup = EditorGUILayout.IntField("Time Group", selected_action.Effect.TargetTimeGroup);

            action_effect_casting_list.character = character;
            action_effect_casting_list.container = selected_action.Effect;
            action_effect_casting_list.OnInspectorGUI();

            action_effect_target_list.character = character;
            action_effect_target_list.container = selected_action.Effect;
            action_effect_target_list.OnInspectorGUI();

            action_effect_hit_list.character = character;
            action_effect_hit_list.container = selected_action.Effect;
            action_effect_hit_list.OnInspectorGUI();

            action_effect_buff_list.character = character;
            action_effect_buff_list.container = selected_action.Effect;
            action_effect_buff_list.OnInspectorGUI();

            action_effect_camera_list.character = character;
            action_effect_camera_list.container = selected_action.Effect;
            action_effect_camera_list.OnInspectorGUI();
        }

        EditorGUILayout.EndVertical();

        EditorGUIUtility.labelWidth = 0f;
        EditorUtility.SetDirty((MonoBehaviour)character);
    }
コード例 #16
0
    private void Hook()
    {
        On("open", (connect) =>
        {
            Debug.Log("connected");
            connectedPlayers = new Dictionary <string, MyNetworkIdentity>();
        });

        On("playerJoin", (join) =>
        {
            GameObject playerLabel = hostingLobby.AddPlayer(join.data["name"].ToString().Replace("\"", string.Empty));
            if (isHost)
            {
                if (join.data["id"].ToString().Replace("\"", string.Empty) == id)
                {
                    playerLabel.GetComponentInChildren <Button>().onClick.AddListener(() => CloseLobby());
                }
                else
                {
                    playerLabel.GetComponentInChildren <Button>().onClick.AddListener(() => KickPlayer(join.data["id"].ToString().Replace("\"", string.Empty)));
                }
            }
            else
            {
                if (join.data["id"].ToString().Replace("\"", string.Empty) == id)
                {
                    playerLabel.GetComponentInChildren <Button>().onClick.AddListener(() => LeaveLobby());
                }
                else
                {
                    playerLabel.GetComponentInChildren <Button>().gameObject.SetActive(false);
                }
            }

            MyNetworkIdentity playerID = playerLabel.GetComponent <MyNetworkIdentity>();
            playerID.SetID(join.data["id"].ToString().Replace("\"", string.Empty));
            playerID.Socket = this;
            connectedPlayers.Add(join.data["id"].ToString().Replace("\"", string.Empty), playerID);
        });
        On("kicked", (kicked) =>
        {
            LeaveLobby();
        });
        On("onRegister", (register) =>
        {
            string a = register.data["id"].ToString().Replace("\"", string.Empty);
            Debug.Log(a);
            id = register.data["id"].ToString().Replace("\"", string.Empty);
            SimpleMessage nameData = new SimpleMessage();
            nameData.message       = playerName;
            Emit("setName", new JSONObject(JsonUtility.ToJson(nameData)));
            serverConnection = true;
            Emit("joinLobby");
        });

        /*
         * On("updateIn", (updateTransform) =>
         * {
         *  float x = updateTransform.data["position"]["x"].f;
         *  float y = updateTransform.data["position"]["y"].f;
         *  float z = updateTransform.data["position"]["z"].f;
         *  connectedPlayers[updateTransform.data["id"].ToString()].gameObject.transform.position = new Vector3(x, y, z);
         *  Debug.Log(updateTransform.data["id"].ToString());
         * });*/

        On("spawnObj", (spawnObject) => {
            GameObject spawneable = Instantiate(serverObj.GetObject(spawnObject.data["objectName"].ToString().Replace("\"", string.Empty)).prefav);
            float x = spawnObject.data["position"]["x"].f;
            float y = spawnObject.data["position"]["y"].f;
            float z = spawnObject.data["position"]["z"].f;
            spawneable.transform.position = new Vector3(x, y, z);
            SpawnedObjects.Add(spawnObject.data["id"].ToString().Replace("\"", string.Empty), new ServerObject());
        });
        On("unspawnObj", (unspawnObject) => {
            string objID = unspawnObject.data["id"].ToString().Replace("\"", string.Empty);
            GameObject objectToDestroy = SpawnedObjects[objID].prefav;
            Destroy(objectToDestroy);
            SpawnedObjects.Remove(objID);
        });
        On("updateObj", (updateObj) => {
            string objID = updateObj.data["id"].ToString().Replace("\"", string.Empty);
            GameObject objectToDestroy = SpawnedObjects[objID].prefav;
            Destroy(objectToDestroy);
            SpawnedObjects.Remove(objID);
        });

        On("disconnect", (disconection) =>
        {
            serverConnection           = false;
            GameObject objectToDestroy = connectedPlayers[id].gameObject;
            Destroy(objectToDestroy);
            connectedPlayers.Remove(id);
        });
        On("playerDisconnected", (disconection) =>
        {
            string playerID            = disconection.data["id"].ToString().Replace("\"", string.Empty);
            GameObject objectToDestroy = connectedPlayers[playerID].gameObject;
            Destroy(objectToDestroy);
            connectedPlayers.Remove(playerID);
        }
           );
        On("startGame", (start) =>
        {
            ChangeScene("GameScene");
        }
           );
        On("newTurn", (NewTurn) =>
        {
            currentGameDirector.NewTurn();
        }
           );
        On("endTurn", (EndTurn) =>
        {
            currentGameDirector.EndOfTurn();
        }
           );
        On("recieveActionData", (RecievedData) =>
        {
            CharacterActionData data = JsonUtility.FromJson <CharacterActionData>(RecievedData.data.ToString());
            currentGameDirector.ReceiveActionToReplicate(data);
        }
           );
        On("startActionTurn", (actions) =>
        {
            currentGameDirector.StartReplication();
        }
           );
    }
コード例 #17
0
    public CharacterAction_EffectContainer Clone(CharacterActionData action_data, Character self, List <ISkillTarget> targets)
    {
        CharacterAction_EffectContainer new_container = new CharacterAction_EffectContainer();

        new_container.m_ActionData = action_data;
        new_container.ScaleTime    = this.ScaleTime;
        new_container.MoveScale    = this.MoveScale;
        new_container.JumpScale    = this.JumpScale;
        new_container.FxHeight     = this.FxHeight;

        List <CharacterAction_EffectCasting> casting = new List <CharacterAction_EffectCasting>();

        for (int i = 0; i < Casting.Length; ++i)
        {
            if (action_data == null || Casting[i].IsEnable == true)
            {
                casting.Add(Casting[i].Clone(action_data, self));
            }
        }
        new_container.Casting = casting.ToArray();

        if (action_data != null)
        {
            float first_action_time = -1f, last_action_time = 0f;

            int target_count = targets == null ? 0 : targets.Count;

            List <CharacterAction_EffectTarget> effect_target = new List <CharacterAction_EffectTarget>();
            List <CharacterAction_EffectHit>    effect_hit    = new List <CharacterAction_EffectHit>();
            List <CharacterAction_EffectBuff>   effect_buff   = new List <CharacterAction_EffectBuff>();
            List <CharacterAction_EffectCamera> effect_camera = new List <CharacterAction_EffectCamera>();

            List <CharacterAction_EffectTarget> temp_effect_target = new List <CharacterAction_EffectTarget>();
            for (int target_index = 0; target_index < target_count; ++target_index)
            {
                if (targets[target_index] == null)
                {
                    continue;
                }

                float time_gap = (target_index == 0 || TargetTimeGroup == 0) ? 0f : (TargetTimeGap * ((target_index - 1) / TargetTimeGroup + 1));

                if (UseSingTarget == false)
                {
                    temp_effect_target.Clear();
                }

                if (UseSingTarget == false || target_index == 0)
                {
                    for (int i = 0; i < Target.Length; ++i)
                    {
                        if (Target[i].IsEnable == false)
                        {
                            continue;
                        }

                        int effect_target_count = Math.Max(1, Target[i].count);
                        for (int et = 0; et < effect_target_count; ++et)
                        {
                            CharacterAction_EffectTarget new_data = Target[i].Clone(action_data, self, targets[target_index].Character);
                            new_data.time += time_gap + et * Target[i].time_tick;
                            effect_target.Add(new_data);
                            temp_effect_target.Add(new_data);
                        }
                    }
                }

                if (targets[target_index] == null || targets[target_index].Character == null || targets[target_index].Character.Creature.IsDead == true)
                {
                    continue;
                }

                if (Hit.Length > 0)
                {
                    List <float> hits             = new List <float>();
                    int          hit_chance_total = 0;
                    for (int i = 0; i < Hit.Length; ++i)
                    {
                        if (Hit[i].IsEnable == false)
                        {
                            continue;
                        }

                        if (Hit[i].target_linked == true)
                        {
                            for (int j = 0; j < temp_effect_target.Count; ++j)
                            {
                                hits.Add(Hit[i].chance);
                                hit_chance_total += Hit[i].chance;
                            }
                        }
                        else
                        {
                            for (int hit_index = 0; hit_index < Hit[i].count; ++hit_index)
                            {
                                hits.Add(Hit[i].chance);
                                hit_chance_total += Hit[i].chance;
                            }
                        }
                    }
                    hits = hits.Select(h => h / hit_chance_total).ToList();

                    targets[target_index].InitHit(hits);
                    for (int i = 0, hit_index = 0; i < Hit.Length; ++i)
                    {
                        CharacterAction_EffectHit hit = Hit[i];
                        if (hit.IsEnable == false)
                        {
                            continue;
                        }

                        if (hit.target_linked)
                        {
                            foreach (CharacterAction_EffectTarget target in temp_effect_target)
                            {
                                CharacterAction_EffectHit new_data = hit.Clone(action_data, self.Creature, targets[target_index], target);
                                new_data.time    += target.time + (UseSingTarget == true?time_gap:0f);
                                new_data.HitIndex = hit_index++;
                                effect_hit.Add(new_data);
                            }
                        }
                        else
                        {
                            for (int hit_count_index = 0; hit_count_index < hit.count; ++hit_count_index)
                            {
                                float hit_time_gap = (target_index == 0 || TargetTimeGroup == 0) ? 0f : ((hit.time_gap == 0f?TargetTimeGap:hit.time_gap) * ((target_index - 1) / TargetTimeGroup + 1));

                                CharacterAction_EffectHit new_data = hit.Clone(action_data, self == null ? null : self.Creature, targets[target_index], null);
                                new_data.time    += hit_time_gap + hit_count_index * new_data.time_tick;
                                new_data.HitIndex = hit_index++;
                                effect_hit.Add(new_data);
                            }
                        }
                    }
                    if (effect_hit.Count > 0)
                    {
                        first_action_time = effect_hit[0].time;
                        last_action_time  = effect_hit[effect_hit.Count - 1].time;
                    }
                }

                if (Buff.Length > 0)
                {
                    for (int i = 0; i < Buff.Length; ++i)
                    {
                        CharacterAction_EffectBuff buff = Buff[i];
                        if (buff.IsEnable == false)
                        {
                            continue;
                        }

                        if (buff.target_linked)
                        {
                            foreach (CharacterAction_EffectTarget target in temp_effect_target)
                            {
                                CharacterAction_EffectBuff new_data = buff.Clone(action_data, self.Creature, targets[target_index], null);
                                new_data.time += target.time + (UseSingTarget == true ? time_gap : 0f);
                                effect_buff.Add(new_data);
                            }
                        }
                        else
                        {
                            CharacterAction_EffectBuff new_data = buff.Clone(action_data, self == null?null:self.Creature, targets[target_index], null);
                            new_data.time += time_gap;
                            effect_buff.Add(new_data);
                        }
                    }
                    if (effect_buff.Count > 0)
                    {
                        if (first_action_time == -1f)
                        {
                            first_action_time = effect_buff[0].time;
                        }
                        else
                        {
                            first_action_time = Mathf.Min(first_action_time, effect_buff[0].time);
                        }

                        last_action_time = Mathf.Max(last_action_time, effect_buff[effect_buff.Count - 1].time);
                    }
                }

                if (Camera.Length > 0)
                {
                    for (int i = 0; i < Camera.Length; ++i)
                    {
                        CharacterAction_EffectCamera camera = Camera[i];
                        if (camera.IsEnable == false)
                        {
                            continue;
                        }

                        if (camera.target_linked)
                        {
                            foreach (CharacterAction_EffectTarget target in temp_effect_target)
                            {
                                CharacterAction_EffectCamera new_data = camera.Clone(action_data, self.Creature, targets[target_index], null);
                                new_data.time += target.time + (UseSingTarget == true ? time_gap : 0f);
                                effect_camera.Add(new_data);
                            }
                        }
                        else
                        {
                            CharacterAction_EffectCamera new_data = camera.Clone(action_data, self == null ? null : self.Creature, targets[target_index], null);
                            new_data.time += time_gap;
                            effect_camera.Add(new_data);
                        }
                    }
                    if (effect_camera.Count > 0)
                    {
                        if (first_action_time == -1f)
                        {
                            first_action_time = effect_camera[0].time;
                        }
                        else
                        {
                            first_action_time = Mathf.Min(first_action_time, effect_camera[0].time);
                        }

                        last_action_time = Mathf.Max(last_action_time, effect_camera[effect_camera.Count - 1].time);
                    }
                }
            }

            new_container.Target          = effect_target.ToArray();
            new_container.Hit             = effect_hit.ToArray();
            new_container.Buff            = effect_buff.ToArray();
            new_container.Camera          = effect_camera.ToArray();
            new_container.FirstActionTime = first_action_time;
            new_container.LastActionTime  = last_action_time;
        }
        else
        {
            new_container.Target = new CharacterAction_EffectTarget[Target.Length];
            for (int i = 0; i < Target.Length; ++i)
            {
                new_container.Target[i] = Target[i].Clone(null, null, null);
            }

            new_container.Hit = new CharacterAction_EffectHit[Hit.Length];
            for (int i = 0; i < Hit.Length; ++i)
            {
                new_container.Hit[i] = Hit[i].Clone(null, null, null, null);
            }

            new_container.Buff = new CharacterAction_EffectBuff[Buff.Length];
            for (int i = 0; i < Buff.Length; ++i)
            {
                new_container.Buff[i] = Buff[i].Clone(null, null, null, null);
            }

            new_container.Camera = new CharacterAction_EffectCamera[Camera.Length];
            for (int i = 0; i < Camera.Length; ++i)
            {
                new_container.Camera[i] = Camera[i].Clone(null, null, null, null);
            }
        }

        return(new_container);
    }