示例#1
0
 public ParsedCombatItem(long time, ulong srcAgent, ulong dstAgent, int value, int buffDmg, uint overstackValue,
                         uint skillId, ushort srcAgentId, ushort dstAgentId, ushort srcMasterId, ushort dstMasterId, FriendOrFoe iff, byte buff,
                         Result result, Activation isActivation, BuffRemove isBuffRemove, byte isNinety, byte isFifty,
                         byte isMoving, StateChange isStateChange, byte isFlanking, byte isShields, byte isOffCycle, uint padding)
 {
     Time           = time;
     SrcAgent       = srcAgent;
     DstAgent       = dstAgent;
     Value          = value;
     BuffDmg        = buffDmg;
     OverstackValue = overstackValue;
     SkillId        = skillId;
     SrcAgentId     = srcAgentId;
     DstAgentId     = dstAgentId;
     SrcMasterId    = srcMasterId;
     DstMasterId    = dstMasterId;
     Iff            = iff;
     Buff           = buff;
     Result         = result;
     IsActivation   = isActivation;
     IsBuffRemove   = isBuffRemove;
     IsNinety       = isNinety;
     IsFifty        = isFifty;
     IsMoving       = isMoving;
     IsStateChange  = isStateChange;
     IsFlanking     = isFlanking;
     IsShields      = isShields;
     IsOffCycle     = isOffCycle;
     Padding        = padding;
 }
示例#2
0
        private static ParsedCombatItem ReadCombatItemRevision1(ByteArrayBinaryReader reader)
        {
            // 8 bytes: time
            long time = reader.ReadInt64();

            // 8 bytes: src_agent
            ulong srcAgent = reader.ReadUInt64();

            // 8 bytes: dst_agent
            ulong dstAgent = reader.ReadUInt64();

            // 4 bytes: value
            int value = reader.ReadInt32();

            // 4 bytes: buff_dmg
            int buffDmg = reader.ReadInt32();

            // 4 bytes: overstack_value
            uint overstackValue = reader.ReadUInt32();

            // 4 bytes: skill_id
            uint skillId = reader.ReadUInt32();

            // 2 bytes: src_instid
            ushort srcInstid = reader.ReadUInt16();

            // 2 bytes: dst_instid
            ushort dstInstid = reader.ReadUInt16();

            // 2 bytes: src_master_instid
            ushort srcMasterInstid = reader.ReadUInt16();

            // 2 bytes: dst_master_instid
            ushort dstMasterInstid = reader.ReadUInt16();

            // 1 byte: iff
            FriendOrFoe iff = GetFriendOrFoeFromByte(reader.ReadByte());

            // 1 byte: buff
            byte buff = reader.ReadByte();

            // 1 byte: result
            Result result = GetResultFromByte(reader.ReadByte());

            // 1 byte: is_activation
            Activation isActivation = GetActivationFromByte(reader.ReadByte());

            // 1 byte: is_buffremove
            BuffRemove isBuffRemove = GetBuffRemoveFromByte(reader.ReadByte());

            // 1 byte: is_ninety
            byte isNinety = reader.ReadByte();

            // 1 byte: is_fifty
            byte isFifty = reader.ReadByte();

            // 1 byte: is_moving
            byte isMoving = reader.ReadByte();

            // 1 byte: is_statechange
            StateChange isStateChange = GetStateChangeFromByte(reader.ReadByte());

            // 1 byte: is_flanking
            byte isFlanking = reader.ReadByte();

            // 1 byte: is_shields
            byte isShields = reader.ReadByte();

            // 1 byte: is_offcycle
            byte isOffcycle = reader.ReadByte();

            // 4 bytes: "padding"
            uint padding = reader.ReadUInt32();

            return(new ParsedCombatItem(time, srcAgent, dstAgent, value, buffDmg, overstackValue, skillId,
                                        srcInstid, dstInstid, srcMasterInstid, dstMasterInstid, iff, buff, result, isActivation, isBuffRemove,
                                        isNinety, isFifty, isMoving, isStateChange, isFlanking, isShields, isOffcycle, padding));
        }
    void FillModifyData()
    {
        characterName  = characterToModify.name;
        characterLayer = characterToModify.layer;
        characterTag   = characterToModify.tag;
        if (characterToModify.GetComponent <Player_CharacterController>() != null)
        {
            playerOrNPC = PlayerOrNPC.player;
            if (characterToModify.GetComponent <Player_CharacterController>().clickToMove)
            {
                movementType = MovementType.ClickToMove;
            }
            else
            {
                movementType = MovementType.WASD;
            }
        }
        if (characterToModify.GetComponent <NPC_CharacterController>() != null)
        {
            playerOrNPC = PlayerOrNPC.NPC;
            if (characterToModify.GetComponent <NPC_CharacterController>().friendOrFoe == NPC_CharacterController.FriendOrFoe.enemy)
            {
                friendOrFoe = FriendOrFoe.enemy;
                if (characterToModify.GetComponent <NPC_CharacterController>().patrolType == State_Patrol.PatrolType.Circular)
                {
                    patrolType = PatrolType.circular;
                }
                if (characterToModify.GetComponent <NPC_CharacterController>().patrolType == State_Patrol.PatrolType.ForthAndBack)
                {
                    patrolType = PatrolType.forthAndBack;
                }
                if (characterToModify.GetComponent <NPC_CharacterController>().patrolType == State_Patrol.PatrolType.Roam)
                {
                    patrolType = PatrolType.roam;
                }
                patrolObject = characterToModify.GetComponent <NPC_CharacterController>().patrolPointsObject.transform;
                attackRange  = characterToModify.GetComponent <Character>().attackRange;
            }
            else
            {
                friendOrFoe = FriendOrFoe.friendly;
            }
        }
        if (characterToModify.GetComponent <Animator>().runtimeAnimatorController != null)
        {
            animator = characterToModify.GetComponent <Animator>().runtimeAnimatorController;
        }
        if (characterToModify.GetComponent <Character>().mainHand != null)
        {
            useSpecifiedTransformForHands.target = true;
            mainHand = characterToModify.GetComponent <Character>().mainHand;
        }
        if (characterToModify.GetComponent <Character>().offHand != null)
        {
            useSpecifiedTransformForHands.target = true;
            offHand = characterToModify.GetComponent <Character>().offHand;
        }
        if (characterToModify.GetComponent <Character>().attackPoint != null)
        {
            attackPoint = characterToModify.GetComponent <Character>().attackPoint;
        }
        baseSpeed = characterToModify.GetComponent <Character>().baseSpeed;

        if (characterToModify.GetComponent <Player_CharacterController>() != null && characterToModify.GetComponent <Player_CharacterController>().usesFieldOfView || characterToModify.GetComponent <NPC_CharacterController>() != null && characterToModify.GetComponent <NPC_CharacterController>().usesFieldOfView)
        {
            shouldUseFieldOfView.target = true;
            if (playerOrNPC == PlayerOrNPC.player)
            {
                fieldOfViewMat = characterToModify.GetComponent <Player_CharacterController>().filter.gameObject.GetComponent <MeshRenderer>().sharedMaterial;

                //Some way to get the obstacle and target layer here

                obstacleLayer = Mathf.RoundToInt(Mathf.Log(characterToModify.GetComponent <Player_CharacterController>().obstacleAndTargetMasks[0].value, 2));
                targetLayer   = Mathf.RoundToInt(Mathf.Log(characterToModify.GetComponent <Player_CharacterController>().obstacleAndTargetMasks[1].value, 2));

                fieldOfViewRadius = Mathf.RoundToInt(characterToModify.GetComponent <Player_CharacterController>().viewRadiusAnglesResolution.x);
                fieldOfViewAngle  = Mathf.RoundToInt(characterToModify.GetComponent <Player_CharacterController>().viewRadiusAnglesResolution.y);
            }
            else
            {
                fieldOfViewMat = characterToModify.GetComponent <NPC_CharacterController>().fowFilter.gameObject.GetComponent <MeshRenderer>().sharedMaterial;

                //Some way to get the obstacle and target layer here
                obstacleLayer = Mathf.RoundToInt(Mathf.Log(characterToModify.GetComponent <NPC_CharacterController>().obstaclesAndTargetMasks[0].value, 2));
                targetLayer   = Mathf.RoundToInt(Mathf.Log(characterToModify.GetComponent <NPC_CharacterController>().obstaclesAndTargetMasks[1].value, 2));

                fieldOfViewRadius = Mathf.RoundToInt(characterToModify.GetComponent <NPC_CharacterController>().viewRadiusAnglesResolution.x);
                fieldOfViewAngle  = Mathf.RoundToInt(characterToModify.GetComponent <NPC_CharacterController>().viewRadiusAnglesResolution.y);
            }
        }

        foreach (Transform transform in characterToModify.GetComponentInChildren <Transform>())
        {
            if (transform.gameObject.name == "CharacterModel")
            {
                characterModel = transform.gameObject;
            }
        }
    }
    private void OnGUI()
    {
        // --- GUI Styles ---
        GUIStyle textStyle1 = new GUIStyle();

        textStyle1.fontSize  = 12;
        textStyle1.fontStyle = FontStyle.Italic;

        GUIStyle title = new GUIStyle();

        title.fontSize  = 14;
        title.fontStyle = FontStyle.Bold;

        GUIStyle boldText = new GUIStyle();

        boldText.margin.left = 3;
        boldText.fontStyle   = FontStyle.Bold;


        // --- ---

        // --- Introduction! ---
        EditorGUILayout.Space();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (createOrModify == CreateOrModify.modify)
        {
            GUILayout.Label("Character Modification", title);
        }
        else
        {
            GUILayout.Label("Character Creation", title);
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        EditorGUILayout.Space();
        // --- ---

        EditorGUI.BeginChangeCheck();
        createOrModify = (CreateOrModify)EditorGUILayout.EnumPopup("Create or Modify", createOrModify);
        if (createOrModify == CreateOrModify.create && EditorGUI.EndChangeCheck())
        {
            ResetCreationData();
        }


        if (createOrModify == CreateOrModify.create)
        {
            modifyCharacter.target = false;
        }
        else
        {
            modifyCharacter.target = true;
        }

        if (EditorGUILayout.BeginFadeGroup(modifyCharacter.faded))
        {
            EditorGUI.indentLevel++;

            EditorGUI.BeginChangeCheck();
            characterToModify = EditorGUILayout.ObjectField("Character to modify", characterToModify, typeof(GameObject), true) as GameObject;
            if (characterToModify != null && EditorGUI.EndChangeCheck())
            {
                FillModifyData();
            }

            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndFadeGroup();
        DrawHorizontalUILine(Color.gray, 1, 4, 45);
        EditorGUILayout.Space();

        // --- Character centered information ---
        GUILayout.Label("Character Information", boldText);

        characterName = EditorGUILayout.TextField(new GUIContent("Character Name"), characterName);

        characterLayer = EditorGUILayout.LayerField(new GUIContent("Layer for the character", "This is optional but reccomended"), characterLayer);
        characterTag   = EditorGUILayout.TagField(new GUIContent("Tag for the character", "This is optional but reccomended"), characterTag);
        maxHealth      = EditorGUILayout.IntField(new GUIContent("Max health", "Will default to 100"), maxHealth);


        // --- ---

        // --- Logic centered information ---

        if (createOrModify == CreateOrModify.create)
        {
            playerOrNPC = (PlayerOrNPC)EditorGUILayout.EnumPopup("Player or NPC", playerOrNPC);
        }


        if (playerOrNPC == PlayerOrNPC.player)
        {
            showNPCCenteredInfo.target    = false;
            showPlayerCenteredInfo.target = true;
        }
        else
        {
            showNPCCenteredInfo.target    = true;
            showPlayerCenteredInfo.target = false;
        }

        // --- Player centered logic ---
        if (EditorGUILayout.BeginFadeGroup(showPlayerCenteredInfo.faded))
        {
            DrawHorizontalUILine(Color.gray, 1, 4, 45);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Player centered logic", textStyle1);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            EditorGUI.indentLevel++;

            movementType = (MovementType)EditorGUILayout.EnumPopup("Movement Type", movementType);

            EditorGUI.indentLevel--;
            DrawHorizontalUILine(Color.gray, 1, 4, 45);
        }
        EditorGUILayout.EndFadeGroup();
        // ---

        // --- NPC centered Logic ---
        if (EditorGUILayout.BeginFadeGroup(showNPCCenteredInfo.faded))
        {
            DrawHorizontalUILine(Color.gray, 1, 4, 45);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("NPC centered logic", textStyle1);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            EditorGUI.indentLevel++;

            //As Friendly NPC Logic is not implemented, we will not allow for this for now and will instead just set friendOrFoe to enemy.
            //friendOrFoe = (FriendOrFoe)EditorGUILayout.EnumPopup("Friendly or Enemy", friendOrFoe);
            friendOrFoe = FriendOrFoe.enemy;
            // This will be fixed by removing the friendOrFoe = enemy and uncommenting the line above it when friendly Logic has been implemented

            if (friendOrFoe == FriendOrFoe.enemy)
            {
                patrolType   = (PatrolType)EditorGUILayout.EnumPopup("Patrol Type", patrolType);
                patrolObject = EditorGUILayout.ObjectField(new GUIContent("Patrol object", "If patrol type != 'Roam', this is the parent object and will need the patrol points childed. If it is, this will be the center of the roam patrol"), patrolObject, typeof(Transform), true) as Transform;
                if (patrolType == PatrolType.roam)
                {
                    roaming.target = true;
                }
                else
                {
                    roaming.target = false;
                }
                if (EditorGUILayout.BeginFadeGroup(roaming.faded))
                {
                    EditorGUI.indentLevel++;
                    roamRadius = EditorGUILayout.FloatField(new GUIContent("Radius", "The radius of the roam patrol type"), roamRadius);
                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.EndFadeGroup();
            }
            else
            {
                EditorGUILayout.HelpBox("Friendly NPC behaviour has not been implemented yet, and will be coming shortly", MessageType.Info);
            }

            attackRange = EditorGUILayout.FloatField(new GUIContent("Attack range", "The range an enemy will need to be from the player to start attacking. It is defaulted to 5 because of the reach of the attack"), attackRange);


            EditorGUI.indentLevel--;
            DrawHorizontalUILine(Color.gray, 1, 4, 45);
        }
        EditorGUILayout.EndFadeGroup();
        // ---

        EditorGUILayout.Space();

        baseSpeed = EditorGUILayout.Slider(new GUIContent("Base speed", "Base speed before any modification. This is in units traveled per second"), baseSpeed, 3.5f, 15f);

        // --- ---

        // --- Advanced character information ---
        advancedCharacterInfo = EditorGUILayout.Foldout(advancedCharacterInfo, "Advanced character info", true);
        if (advancedCharacterInfo)
        {
            EditorGUI.indentLevel++;

            if (createOrModify != CreateOrModify.modify)
            {
                appendIDToName.target = EditorGUILayout.ToggleLeft(new GUIContent("Append ID to Name", "Appends a nummerical ID to the end of the name"), appendIDToName.target);
                if (EditorGUILayout.BeginFadeGroup(appendIDToName.faded))
                {
                    EditorGUI.indentLevel++;

                    characterID = EditorGUILayout.IntField("Character ID", characterID);

                    EditorGUI.indentLevel--;
                    DrawHorizontalUILine(Color.gray, 1, 4, 45);
                }
                EditorGUILayout.EndFadeGroup();
            }

            shouldUseFieldOfView.target = EditorGUILayout.ToggleLeft("Use Field Of View", shouldUseFieldOfView.target);
            if (EditorGUILayout.BeginFadeGroup(shouldUseFieldOfView.faded))
            {
                EditorGUI.indentLevel++;

                fieldOfViewMat = EditorGUILayout.ObjectField("Material for the FOW", fieldOfViewMat, typeof(Material), false) as Material;

                obstacleLayer = EditorGUILayout.LayerField(new GUIContent("Obstacle layer", "Sets the layer for obstacles for the FOW"), obstacleLayer);
                targetLayer   = EditorGUILayout.LayerField(new GUIContent("Target layer", "Sets the layer for targets for the FOW"), targetLayer);

                fieldOfViewRadius = EditorGUILayout.IntField(new GUIContent("Field of view radius", "The radius of the field of view"), fieldOfViewRadius);
                if (fieldOfViewRadius < 0)
                {
                    fieldOfViewRadius = 0;
                }
                fieldOfViewAngle = EditorGUILayout.IntSlider(new GUIContent("Field of view angle", "The angle of the field of view"), fieldOfViewAngle, 0, 360);

                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();


            EditorGUI.indentLevel--;
        }
        // ---


        DrawHorizontalUILine(Color.gray);
        // --- ---

        EditorGUILayout.Space();

        // --- Object centered basic information ---
        GUILayout.Label("Basic Object information", boldText);
        //GUILayout.Box("FOO", GUILayout.ExpandWidth(true));

        characterModel = EditorGUILayout.ObjectField("Character Model:", characterModel, typeof(GameObject), true) as GameObject;

        // --- Advanced object info ---
        advancedObjectInfo = EditorGUILayout.Foldout(advancedObjectInfo, "Advanced object info", true);
        if (advancedObjectInfo)
        {
            EditorGUI.indentLevel++;

            if (createOrModify != CreateOrModify.modify)
            {
                modelUsesEmptyParent = EditorGUILayout.ToggleLeft(new GUIContent("Model uses empty parent", "Will not child the model to an empty Game Object"), modelUsesEmptyParent);

                useSpecifiedParent.target = EditorGUILayout.ToggleLeft(new GUIContent("Use specified parent object", "will use specified Game Object as parent"), useSpecifiedParent.target);
                if (EditorGUILayout.BeginFadeGroup(useSpecifiedParent.faded))
                {
                    specifiedParent = EditorGUILayout.ObjectField(new GUIContent("Parent Object", "This needs to be a scene object"), specifiedParent, typeof(Transform), true) as Transform;
                }
                else
                {
                    specifiedParent = null;
                }
                EditorGUILayout.EndFadeGroup();
            }

            useSpecifiedTransformForHands.target = EditorGUILayout.ToggleLeft(new GUIContent("Use specified transform for hands"), useSpecifiedTransformForHands.target);
            if (EditorGUILayout.BeginFadeGroup(useSpecifiedTransformForHands.faded))
            {
                mainHand = EditorGUILayout.ObjectField(new GUIContent("Main hand transform", "If left empty, the tool will create one at position 0.75,0.75,0"), mainHand, typeof(Transform), true) as Transform;
                offHand  = EditorGUILayout.ObjectField(new GUIContent("Off hand transform", "If left empty, the tool will create one at position -0.75,0.75,0"), offHand, typeof(Transform), true) as Transform;
            }
            EditorGUILayout.EndFadeGroup();
            if (useSpecifiedTransformForHands.value == false)
            {
                usesNameForFindingHands.target = true;
            }
            else
            {
                usesNameForFindingHands.target = false;
            }
            if (EditorGUILayout.BeginFadeGroup(usesNameForFindingHands.faded))
            {
                mainHandName = EditorGUILayout.TextField(new GUIContent("Main hand name in model", "If left empty, or object cannot be found, the tool will create one at position 0.75,0.75,0"), mainHandName);
                offHandName  = EditorGUILayout.TextField(new GUIContent("Off hand name in model", "if left empty, or object cannot be found, the tool will create one at position -0.75,0.75,0"), offHandName);
            }
            EditorGUILayout.EndFadeGroup();

            attackPoint = EditorGUILayout.ObjectField(new GUIContent("Attack point", "This is the point where an attack is calculated around. It is implemented because of the way the system currently works. If left empty, the tool will create one at position 0,1,2"), attackPoint, typeof(Transform), true) as Transform;


            //CreateFadeGroup<Transform>(useSpecifiedParent, "Use specified parent object", specifiedParent, "parent object");



            EditorGUI.indentLevel--;
        }
        // ---

        DrawHorizontalUILine(Color.gray);

        EditorGUILayout.Space();
        // --- ---

        // --- Do you want a prefab with that? ---
        if (createOrModify != CreateOrModify.modify)
        {
            GUILayout.Label("Prefab information", boldText);
            createPrefab.target = EditorGUILayout.ToggleLeft("Save as a Prefab", createPrefab.target);
            if (EditorGUILayout.BeginFadeGroup(createPrefab.faded))
            {
                EditorGUI.indentLevel++;

                prefabPath     = EditorGUILayout.TextField("Prefab Path", prefabPath == string.Empty ? "'Assets/SomeFolder...'" : prefabPath);
                doCreatePrefab = true;
                keepInScene    = EditorGUILayout.ToggleLeft("Keep in scene?", keepInScene);

                EditorGUI.indentLevel--;
            }
            else
            {
                doCreatePrefab = false;
                keepInScene    = false;
            }
            EditorGUILayout.EndFadeGroup();

            DrawHorizontalUILine(Color.gray);

            EditorGUILayout.Space();
        }
        // --- ---

        // --- Animation stuff ---
        GUILayout.Label("Animator information", boldText);

        animator = EditorGUILayout.ObjectField(new GUIContent("Animator controller"), animator, typeof(RuntimeAnimatorController), false) as RuntimeAnimatorController;
        //animator = EditorGUILayout.PropertyField(new GUIContent("Animator goes here"), animator, typeof(RuntimeAnimatorController)) as RuntimeAnimatorController;
        //EditorGUILayout.fiel
        // --- ---



        // --- Creation/Modification button ---
        if (createOrModify == CreateOrModify.create)
        {
            EditorGUI.BeginDisabledGroup(createButtonDisableParams());

            if (GUILayout.Button("Create Character"))
            {
                CreateCharacter();
            }
            EditorGUI.EndDisabledGroup();
        }
        else
        {
            EditorGUI.BeginDisabledGroup(createButtonDisableParams());

            if (GUILayout.Button("Modify Character"))
            {
                ModifyCharacter();
            }
            EditorGUI.EndDisabledGroup();
        }
        EditorGUILayout.Space();
        // --- ---



        //Stuff for errors here..

        // --- Error messages ---

        // Modify stuff
        if (modifyCharacter.value == true && characterToModify == null)
        {
            EditorGUILayout.HelpBox("Please insert character to modify", MessageType.Warning);
        }
        if (modifyCharacter.value == true && characterToModify != null && characterName == string.Empty)
        {
            EditorGUILayout.HelpBox("Please give a Name to the Character", MessageType.Warning);
        }

        // ---

        // Create stuff


        if (characterName == string.Empty && modifyCharacter.value == false)
        {
            EditorGUILayout.HelpBox("Please give a Name to the Character", MessageType.Warning);
        }

        if (characterModel == null && !modifyCharacter.value == true)
        {
            EditorGUILayout.HelpBox("Please insert Character Model", MessageType.Warning);
        }

        if (playerOrNPC == PlayerOrNPC.NPC && patrolObject == null)
        {
            EditorGUILayout.HelpBox("Please insert a patrol object", MessageType.Warning);
        }

        if (shouldUseFieldOfView.value == true && fieldOfViewMat == null)
        {
            EditorGUILayout.HelpBox("Please supply a material for the field of view", MessageType.Warning);
        }

        if (shouldUseFieldOfView.value == true && obstacleLayer == LayerMask.NameToLayer("Default"))
        {
            EditorGUILayout.HelpBox("Obstacle layer should not be default", MessageType.Warning);
        }

        if (shouldUseFieldOfView.value == true && targetLayer == LayerMask.NameToLayer("Default"))
        {
            EditorGUILayout.HelpBox("Target layer should not be default", MessageType.Warning);
        }

        if (useSpecifiedParent.value == true && specifiedParent == null)
        {
            EditorGUILayout.HelpBox("Please supply a parent object", MessageType.Warning);
        }

        if (useSpecifiedParent.value == true && specifiedParent != null && EditorUtility.IsPersistent(specifiedParent))
        {
            EditorGUILayout.HelpBox("Specified parent object needs to be a scene object", MessageType.Warning);
        }

        if (createPrefab.value == true && prefabPath == "'Assets/SomeFolder...'")
        {
            EditorGUILayout.HelpBox("Please insert a valid path name for your prefab", MessageType.Warning);
        }

        // ---

        // --- ---
    }