Example #1
0
    private void SetupCharacter(CharacterSetup setup, int version)
    {
        //if the setup has unimplimented sprites, use cop instead
        if (setup.controllers.Length == 0)
        {
            Debug.LogError("Could not find animation controller for player, defaulting to cop", gameObject);
            setup = this.cop;
        }
        else if (setup.placeholderSprites.Length == 0)
        {
            Debug.LogError("Could not find default sprite(s) for player, defaulting to cop", gameObject);
            setup = this.cop;
        }
        RuntimeAnimatorController[] controllers = setup.controllers;
        Sprite[] sprites = setup.placeholderSprites;
        this.spriteRenderer.flipX = setup.flipSpriteX;
        this.playerController.SetJetpackParticle(setup.jetpackParticle);
        if (version < 0 || version >= controllers.Length)
        {
            Debug.LogError(string.Format("Sprite Animator version: {0} is out of range for {1}", version, gameObject.name));
        }
        else
        {
            this.spriteAnimator.runtimeAnimatorController = controllers[version];
        }

        if (version >= sprites.Length)
        {
            Debug.LogError(string.Format("Sprite Placeholder version: {0} is out of range for {1}", version, gameObject.name));
        }
        else
        {
            this.spriteRenderer.sprite = sprites[version];
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            weaponType = 0;

            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 1000f, hitMask))
            {
                //call the ApplyDamage() function on the enenmy CharacterSetup script
                if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Limb"))
                {
                    Vector3 direction = hit.collider.transform.position - transform.position;

                    if (hit.collider.gameObject.GetComponent <Limb>())
                    {
                        GameObject     parent    = hit.collider.gameObject.GetComponent <Limb>().parent;
                        CharacterSetup character = parent.GetComponent <CharacterSetup>();
                        character.ApplyDamage(damage, hit.collider.gameObject, weaponType, direction, mainCamTransform.position);
                    }
                }
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        _charSetup = FindObjectOfType <CharacterSetup> ();
        filePath   = Application.dataPath + "/" + fileName;

        if (File.Exists(filePath))
        {
        }
    }
    public override void OnInspectorGUI()
    {
        if (!Application.isPlaying)
        {
            CharacterSetup characterSetup = target as CharacterSetup;
            if (GUILayout.Button("Update Sprites"))
            {
                characterSetup.UpdateSprites(false);
            }
        }

        base.OnInspectorGUI();
    }
Example #5
0
    public void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("Limb"))
        {
            if (other.gameObject.GetComponent <Limb>())
            {
                GameObject     limb      = other.gameObject.GetComponent <Limb>().parent;
                CharacterSetup character = limb.GetComponent <CharacterSetup>();

                Vector3 position  = limb.transform.position;
                Vector3 direction = other.gameObject.transform.position - transform.position;

                character.ExplodeBody(position, direction);
            }
        }
    }
Example #6
0
        public void Setup()
        {
            // Get references to the components.
            Movement           = Instance.GetComponent <CharacterMovement>();
            Shooting           = Instance.GetComponent <CharacterShooting>();
            Health             = Instance.GetComponent <CharacterHealth>();
            CharacterBehaviour = Instance.GetComponent <CharacterBehaviour>();
            CharacterShield    = Instance.GetComponent <CharacterShield>();
            CharacterSetup     = Instance.GetComponent <CharacterSetup>();

            Movement.OnDestroyOject += () =>
            {
                Instance           = null;
                Movement           = null;
                Shooting           = null;
                Health             = null;
                CharacterBehaviour = null;
                CharacterShield    = null;
                CharacterSetup     = null;
                GameManager.Characters.Remove(this);
            };

            // Get references to the child objects.
            CharacterRenderers = Health.CharacterRenderers;

            //Set a reference to that amanger in the health script, to disable control when dying
            Health.Manager = this;

            // Set the player numbers to be consistent across the scripts.
            Movement.PlayerNumber = PlayerNumber;
            Movement.LocalID      = LocalPlayerID;

            Shooting.PlayerNumber = PlayerNumber;
            Shooting.localID      = LocalPlayerID;

            //setup is use for diverse Network Related sync
            CharacterSetup.Color        = PlayerColor;
            CharacterSetup.PlayerName   = PlayerName;
            CharacterSetup.PlayerNumber = PlayerNumber;
            CharacterSetup.LocalId      = LocalPlayerID;

            CharacterShield.PlayerNumber = PlayerNumber;
            CharacterShield._character   = CharacterBehaviour;
        }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.L))
        {
            StreamReader sr = new StreamReader(filePath);

            GameObject     player     = Instantiate(Resources.Load("prefabs/Player") as GameObject);
            CharacterSetup _charSetup = player.GetComponent <CharacterSetup> ();

            string line = sr.ReadLine();
            sr.Close();

            string[] splitLine = line.Split(DELIMITER);

            _charSetup.charName = splitLine [0];
            if (System.Enum.IsDefined(typeof(Globals.CharRace), splitLine[1]))
            {
                _charSetup.charRace = (Globals.CharRace)System.Enum.Parse(typeof(Globals.CharRace), splitLine [1]);
            }

            _charSetup.charClass = (Globals.CharClass)System.Enum.Parse(typeof(Globals.CharClass), splitLine [2]);
        }
    }
    // Use this for initialization
    void Start()
    {
        setup = gameObject.GetComponent <CharacterSetup>();

        accuracy = (((((setup.leftUpperArmHealth / setup.maxLeftUpperArmHealth) * 0.5f) +
                      ((setup.rightUpperArmHealth / setup.maxRightUpperArmHealth) * 0.5f)) * maxAccuracy) / maxAccuracy) * 100.0f;
        speed = (((((setup.leftLegHealth / setup.maxLeftLegHealth) * 0.5f) +
                   ((setup.rightLegHealth / setup.maxRightLegHealth) * 0.5f)) * maxAccuracy) / maxAccuracy) * 100.0f;
        meleeDamage = accuracy;
        focus       = (((setup.headHealth / setup.maxHeadHealth) * maxFocus) / maxFocus) * 100.0f;



        totalHealth.text    = ("Total Health:" + ((setup.health / setup.maxHealth) * 100.0f) + "%");
        headHealth.text     = ("Head Health:" + ((setup.headHealth / setup.maxHeadHealth) * 100.0f) + "%");
        rightLegHealth.text = ("Right Leg Health:" + ((setup.rightLegHealth / setup.maxRightLegHealth) * 100.0f) + "%");
        leftLegHealth.text  = ("Left Leg Health:" + ((setup.leftLegHealth / setup.maxLeftLegHealth) * 100.0f) + "%");
        rightArmHealth.text = ("Right Arm Health:" + ((setup.rightUpperArmHealth / setup.maxRightUpperArmHealth) * 100.0f) + "%");
        leftArmHealth.text  = ("Left Arm Health:" + ((setup.leftUpperArmHealth / setup.maxLeftUpperArmHealth) * 100.0f) + "%");
        accuracyAMT.text    = ("Accuracy:" + accuracy + "%");
        speedAMT.text       = ("Speed:" + speed + "%");
        meleeDamageAMT.text = ("Melee Damage:" + meleeDamage + "%");
        focusAMT.text       = ("Focus:" + focus + "%");
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        CharacterSetup setup = (CharacterSetup)target;

        EditorGUILayout.HelpBox("General Setup", MessageType.None, true);
        setup.characterName = EditorGUILayout.TextField("Character Name", setup.characterName);
        setup.loadPrevious  = EditorGUILayout.Toggle("Load Saved", setup.loadPrevious);
        setup.target        = (GameObject)EditorGUILayout.ObjectField("Script Target", setup.target, typeof(GameObject), true);
        EditorGUILayout.HelpBox("Leave target blank if your custom scripts accessing the Damage Event System are on this gameObject. Otherwise place the gameObject your custom scripts are on above.", MessageType.Warning, true);
        setup.renderers  = (GameObject)EditorGUILayout.ObjectField("Renderers Parent", setup.renderers, typeof(GameObject), true);
        setup.skeleton   = (GameObject)EditorGUILayout.ObjectField("Skeleton Parent", setup.skeleton, typeof(GameObject), true);
        setup.usePooling = EditorGUILayout.Toggle("Use Pooling", setup.usePooling);
        if (!setup.usePooling)
        {
            setup.destroyTimer = EditorGUILayout.FloatField("Destruction Timer", setup.destroyTimer);
        }
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.HelpBox("Ragdoll Setup", MessageType.None, true);
        setup.useAutomaticRagdoll = EditorGUILayout.Toggle("Automatic Ragdoll?", setup.useAutomaticRagdoll);
        setup.ragdoll             = (Transform )EditorGUILayout.ObjectField("Ragdoll", setup.ragdoll, typeof(Transform), false);
        setup.ragdollWaitTime     = EditorGUILayout.FloatField("Ragdoll Wait Time", setup.ragdollWaitTime);
        setup.destroyRagdolls     = EditorGUILayout.Toggle("Destroy Ragdolls?", setup.destroyRagdolls);
        if (setup.destroyRagdolls)
        {
            setup.bodyStayTime = EditorGUILayout.FloatField("Ragdoll Stay Time", setup.bodyStayTime);
        }
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();



        EditorGUILayout.HelpBox("Health Setup", MessageType.None, true);
        EditorGUILayout.LabelField("Current Health", setup.health.ToString());
        setup.maxHealth              = EditorGUILayout.FloatField("Max Global Health", setup.maxHealth);
        setup.maxHeadHealth          = EditorGUILayout.FloatField("Max Head Health", setup.maxHeadHealth);
        setup.maxRightHandHealth     = EditorGUILayout.FloatField("Max Right Hand Health", setup.maxRightHandHealth);
        setup.maxLeftHandHealth      = EditorGUILayout.FloatField("Max Left Hand Health", setup.maxLeftHandHealth);
        setup.maxRightLegHealth      = EditorGUILayout.FloatField("Max Right Leg Health", setup.maxRightLegHealth);
        setup.maxLeftLegHealth       = EditorGUILayout.FloatField("Max Left Leg Health", setup.maxLeftLegHealth);
        setup.maxRightUpperArmHealth = EditorGUILayout.FloatField("Max Right Upper Arm Health", setup.maxRightUpperArmHealth);
        setup.maxLeftUpperArmHealth  = EditorGUILayout.FloatField("Max Left Upper Arm Health", setup.maxLeftUpperArmHealth);
        setup.maxRightForArmHealth   = EditorGUILayout.FloatField("Max Right Forearm Health", setup.maxRightForArmHealth);
        setup.maxLeftForArmHealth    = EditorGUILayout.FloatField("Max Left Forearm Health", setup.maxLeftForArmHealth);
        setup.maxExtra1Health        = EditorGUILayout.FloatField("Max Extra Part 1 Health", setup.maxExtra1Health);
        setup.maxExtra2Health        = EditorGUILayout.FloatField("Max Extra Part 2 Health", setup.maxExtra2Health);
        setup.maxExtra3Health        = EditorGUILayout.FloatField("Max Extra Part 3 Health", setup.maxExtra3Health);
        setup.maxExtra4Health        = EditorGUILayout.FloatField("Max Extra Part 4 Health", setup.maxExtra4Health);
        EditorGUILayout.HelpBox("If you set a body parts Max Health above Max Global Health (and dont set a higher damage multiplier) " +
                                "you can make a body part not die even with useBodyDismemberment set to true!", MessageType.Info, true);
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.HelpBox("Damage Multiplier Setup", MessageType.None, true);
        setup.criticalMultiplier = EditorGUILayout.FloatField("Critical Multiplier", setup.criticalMultiplier);
        setup.headMultiplier     = EditorGUILayout.FloatField("Head Multiplier", setup.headMultiplier);
        setup.handMultiplier     = EditorGUILayout.FloatField("Hand Multiplier", setup.handMultiplier);
        setup.armMultiplier      = EditorGUILayout.FloatField("Arm Multiplier", setup.armMultiplier);
        setup.legMultiplier      = EditorGUILayout.FloatField("Leg Multiplier", setup.legMultiplier);
        setup.bodyMultiplier     = EditorGUILayout.FloatField("Body Multiplier", setup.bodyMultiplier);
        setup.extra1Multiplier   = EditorGUILayout.FloatField("Extra Part 1 Multiplier", setup.extra1Multiplier);
        setup.extra2Multiplier   = EditorGUILayout.FloatField("Extra Part 2 Multiplier", setup.extra2Multiplier);
        setup.extra3Multiplier   = EditorGUILayout.FloatField("Extra Part 3 Multiplier", setup.extra3Multiplier);
        setup.extra4Multiplier   = EditorGUILayout.FloatField("Extra Part 4 Multiplier", setup.extra4Multiplier);
        EditorGUILayout.HelpBox("If you set a body part's multiplier to zero it will not only apply no damage to it, " +
                                "but will pass no damage onto the total health either. Only set a multiplier to zero if you are not using that limb.", MessageType.Warning, true);
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();


        EditorGUILayout.HelpBox("Dismember Setup", MessageType.None, true);
        setup.advancedRagdoll    = EditorGUILayout.Toggle("Use Advanced Ragdoll", setup.advancedRagdoll);
        setup.useHeadDismember   = EditorGUILayout.Toggle("Use Head Dismember?", setup.useHeadDismember);
        setup.useBodyDismember   = EditorGUILayout.Toggle("Use Body Dismember?", setup.useBodyDismember);
        setup.useExplosion       = EditorGUILayout.Toggle("Use Explosive Dismember?", setup.useExplosion);
        setup.weaponTypeForHead  = EditorGUILayout.IntField("Weapon Type Head ", setup.weaponTypeForHead);
        setup.weaponTypeForLimbs = EditorGUILayout.IntField("Weapon Type Limb ", setup.weaponTypeForLimbs);
        setup.weaponTypeForBody  = EditorGUILayout.IntField("Weapon Type Torso ", setup.weaponTypeForBody);
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (setup.useHeadDismember || setup.useBodyDismember)
        {
            EditorGUILayout.HelpBox("Body Parts To Spawn", MessageType.None, true);
            if (setup.useHeadDismember)
            {
                setup.headModel = (Transform )EditorGUILayout.ObjectField("Head Model", setup.headModel, typeof(Transform), false);
            }
            //Body parts to spawn when shot off
            if (setup.useBodyDismember)
            {
                setup.rightHandModel     = (Transform )EditorGUILayout.ObjectField("Right Hand Model", setup.rightHandModel, typeof(Transform), false);
                setup.leftHandModel      = (Transform )EditorGUILayout.ObjectField("Left Hand Model", setup.leftHandModel, typeof(Transform), false);
                setup.rightLegModel      = (Transform )EditorGUILayout.ObjectField("Right Leg Model", setup.rightLegModel, typeof(Transform), false);
                setup.leftLegModel       = (Transform )EditorGUILayout.ObjectField("Left Leg Model", setup.leftLegModel, typeof(Transform), false);
                setup.rightUpperArmModel = (Transform )EditorGUILayout.ObjectField("Right Upper Arm Model", setup.rightUpperArmModel, typeof(Transform), false);
                setup.leftUpperArmModel  = (Transform )EditorGUILayout.ObjectField("Left Upper Arm Model", setup.leftUpperArmModel, typeof(Transform), false);
                setup.rightForArmModel   = (Transform )EditorGUILayout.ObjectField("Right Forearm Model", setup.rightForArmModel, typeof(Transform), false);
                setup.leftForArmModel    = (Transform )EditorGUILayout.ObjectField("Left Forearm Model", setup.leftForArmModel, typeof(Transform), false);
                setup.upperBodyModel     = (Transform )EditorGUILayout.ObjectField("Upper Body Model", setup.upperBodyModel, typeof(Transform), false);
                setup.extra1Model        = (Transform )EditorGUILayout.ObjectField("Extra Part 1 Model", setup.extra1Model, typeof(Transform), false);
                setup.extra2Model        = (Transform )EditorGUILayout.ObjectField("Extra Part 2 Model", setup.extra2Model, typeof(Transform), false);
                setup.extra3Model        = (Transform )EditorGUILayout.ObjectField("Extra Part 3 Model", setup.extra3Model, typeof(Transform), false);
                setup.extra4Model        = (Transform )EditorGUILayout.ObjectField("Extra Part 4 Model", setup.extra4Model, typeof(Transform), false);
            }
            EditorGUILayout.HelpBox("The above fields can be left blank if your model doesn't have the body part", MessageType.Info, true);
        }
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (setup.useHeadDismember || setup.useBodyDismember)
        {
            EditorGUILayout.HelpBox("Body Part Skinned Meshes", MessageType.None, true);

            if (setup.useHeadDismember)
            {
                EditorGUIUtility.labelWidth = 0;
                EditorGUIUtility.fieldWidth = 0;
                SerializedProperty head = serializedObject.FindProperty("head");
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(head, true);
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
                EditorGUIUtility.labelWidth = 25;
                EditorGUIUtility.fieldWidth = 50;
            }

            if (setup.useBodyDismember)
            {
                EditorGUIUtility.labelWidth = 0;
                EditorGUIUtility.fieldWidth = 0;
                SerializedProperty rightHands    = serializedObject.FindProperty("rightHands");
                SerializedProperty leftHands     = serializedObject.FindProperty("leftHands");
                SerializedProperty rightLegs     = serializedObject.FindProperty("rightLegs");
                SerializedProperty leftLegs      = serializedObject.FindProperty("leftLegs");
                SerializedProperty rightUpperArm = serializedObject.FindProperty("rightUpperArm");
                SerializedProperty leftUpperArm  = serializedObject.FindProperty("leftUpperArm");
                SerializedProperty rightForeArm  = serializedObject.FindProperty("rightForArm");
                SerializedProperty leftForeArm   = serializedObject.FindProperty("leftForArm");
                SerializedProperty upperBody     = serializedObject.FindProperty("upperBody");
                SerializedProperty lowerBody     = serializedObject.FindProperty("lowerBody");
                SerializedProperty extra1        = serializedObject.FindProperty("extra1");
                SerializedProperty extra2        = serializedObject.FindProperty("extra2");
                SerializedProperty extra3        = serializedObject.FindProperty("extra3");
                SerializedProperty extra4        = serializedObject.FindProperty("extra4");
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(rightHands, true);
                EditorGUILayout.PropertyField(leftHands, true);
                EditorGUILayout.PropertyField(rightLegs, true);
                EditorGUILayout.PropertyField(leftLegs, true);
                EditorGUILayout.PropertyField(rightUpperArm, true);
                EditorGUILayout.PropertyField(leftUpperArm, true);
                EditorGUILayout.PropertyField(rightForeArm, true);
                EditorGUILayout.PropertyField(leftForeArm, true);
                EditorGUILayout.PropertyField(upperBody, true);
                EditorGUILayout.PropertyField(lowerBody, true);
                EditorGUILayout.PropertyField(extra1, true);
                EditorGUILayout.PropertyField(extra2, true);
                EditorGUILayout.PropertyField(extra3, true);
                EditorGUILayout.PropertyField(extra4, true);
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
                EditorGUIUtility.labelWidth = 25;
                EditorGUIUtility.fieldWidth = 50;
            }
            EditorGUILayout.HelpBox("The above fields can be left blank if your model doesn't have the body part", MessageType.Info, true);
        }
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();


        if (setup.useExplosion)
        {
            EditorGUILayout.HelpBox("Objects(Parts) To Spawn On An Explosion", MessageType.None, true);
            EditorGUIUtility.labelWidth = 0;
            EditorGUIUtility.fieldWidth = 0;
            SerializedProperty explosionParts = serializedObject.FindProperty("explosionParts");
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(explosionParts, true);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
            EditorGUIUtility.labelWidth = 25;
            EditorGUIUtility.fieldWidth = 50;
        }
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (setup.useHeadDismember || setup.useBodyDismember)
        {
            EditorGUILayout.HelpBox("Body Part Colliders", MessageType.None, true);
            if (setup.useHeadDismember)
            {
                EditorGUIUtility.labelWidth = 0;
                EditorGUIUtility.fieldWidth = 0;
                SerializedProperty headColliders = serializedObject.FindProperty("headColliders");
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(headColliders, true);
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
                EditorGUIUtility.labelWidth = 25;
                EditorGUIUtility.fieldWidth = 50;
            }
            if (setup.useBodyDismember)
            {
                EditorGUIUtility.labelWidth = 0;
                EditorGUIUtility.fieldWidth = 0;
                SerializedProperty rightHandColliders     = serializedObject.FindProperty("rightHandColliders");
                SerializedProperty leftHandColliders      = serializedObject.FindProperty("leftHandColliders");
                SerializedProperty rightLegColliders      = serializedObject.FindProperty("rightLegColliders");
                SerializedProperty leftLegColliders       = serializedObject.FindProperty("leftLegColliders");
                SerializedProperty rightUpperArmColliders = serializedObject.FindProperty("rightUpperArmColliders");
                SerializedProperty leftUpperArmColliders  = serializedObject.FindProperty("leftUpperArmColliders");
                SerializedProperty rightForeArmColliders  = serializedObject.FindProperty("rightForArmColliders");
                SerializedProperty leftForeArmColliders   = serializedObject.FindProperty("leftForArmColliders");
                SerializedProperty upperBodyColliders     = serializedObject.FindProperty("upperBodyColliders");
                SerializedProperty lowerBodyColliders     = serializedObject.FindProperty("lowerBodyColliders");
                SerializedProperty extra1Colliders        = serializedObject.FindProperty("extra1Colliders");
                SerializedProperty extra2Colliders        = serializedObject.FindProperty("extra2Colliders");
                SerializedProperty extra3Colliders        = serializedObject.FindProperty("extra3Colliders");
                SerializedProperty extra4Colliders        = serializedObject.FindProperty("extra4Colliders");
                EditorGUI.BeginChangeCheck();

                EditorGUILayout.PropertyField(rightHandColliders, true);
                EditorGUILayout.PropertyField(leftHandColliders, true);
                EditorGUILayout.PropertyField(rightLegColliders, true);
                EditorGUILayout.PropertyField(leftLegColliders, true);
                EditorGUILayout.PropertyField(rightUpperArmColliders, true);
                EditorGUILayout.PropertyField(leftUpperArmColliders, true);
                EditorGUILayout.PropertyField(rightForeArmColliders, true);
                EditorGUILayout.PropertyField(leftForeArmColliders, true);
                EditorGUILayout.PropertyField(upperBodyColliders, true);
                EditorGUILayout.PropertyField(lowerBodyColliders, true);
                EditorGUILayout.PropertyField(extra1Colliders, true);
                EditorGUILayout.PropertyField(extra2Colliders, true);
                EditorGUILayout.PropertyField(extra3Colliders, true);
                EditorGUILayout.PropertyField(extra4Colliders, true);
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
                EditorGUIUtility.labelWidth = 25;
                EditorGUIUtility.fieldWidth = 50;
                EditorGUILayout.HelpBox("The above fields can be left blank if your model doesn't have the body part", MessageType.Info, true);
            }
        }
    }
 public void Interact(CharacterSetup player)
 {
     throw new System.NotImplementedException();
 }
Example #11
0
 // Use this for initialization
 void Start()
 {
     setup = gameObject.GetComponent <CharacterSetup>();
 }
Example #12
0
        /// <summary>
        /// Handles the specified command (and it's specified arguments).
        /// </summary>
        /// <param name="character">The character to execute command for.</param>
        /// <param name="command">The command to execute.</param>
        /// <param name="arguments">The command arguments.</param>
        public static void Handle(Character character, string command, string[] arguments)
        {
            try
            {
                /*
                 * Commands that are specified for players.
                 */
                if (character.ServerRights >= ServerRights.Player)
                {
                    #region Setup

                    /*
                     * Brings up an interface for character setup.
                     */
                    if (command.Equals("setup"))
                    {
                        CharacterSetup.Show(character);
                    }
                    #endregion Setup

                    #region Clear Inventory

                    /*
                     * Clears the character's inventory.
                     */
                    else if (command.Equals("clearinv"))
                    {
                        character.Inventory.Reset();
                    }
                    #endregion Clear Inventory

                    #region Players

                    /*
                     * Notifies the character how many players are current online.
                     */
                    else if (command.Equals("players"))
                    {
                        int count = GameEngine.World.CharacterManager.CharacterCount;
                        character.Session.SendData(new MessagePacketComposer(
                                                       "There is currently " + count + " player(s) online.").Serialize());
                    }
                    #endregion Players

                    #region Bank

                    /*
                     * Opens the character's bank.
                     */
                    else if (command.Equals("bank"))
                    {
                        Bank.Show(character);
                    }
                    #endregion Bank

                    #region Add Item

                    /*
                     * Spawns an item.
                     */
                    else if (command.Equals("additem"))
                    {
                        if (arguments.Length == 2 || arguments.Length == 3)
                        {
                            short item  = short.Parse(arguments[1]);
                            int   count = 1;

                            if (arguments.Length == 3)
                            {
                                count = int.Parse(arguments[2]);
                            }
                            character.Inventory.AddItem(new Item(item, count));
                        }
                    }
                    #endregion Add Item

                    #region Delete Item

                    /*
                     * Deletes an item.
                     */
                    else if (command.Equals("deleteitem"))
                    {
                        if (arguments.Length == 2 || arguments.Length == 3)
                        {
                            short item  = short.Parse(arguments[1]);
                            int   count = 1;

                            if (arguments.Length == 3)
                            {
                                count = int.Parse(arguments[2]);
                            }
                            character.Inventory.DeleteItem(new Item(item, count));
                        }
                    }
                    #endregion Delete Item
                }

                /*
                 * Commands that are specified for donators.
                 */
                if (character.ServerRights >= ServerRights.Donator)
                {
                }

                /*
                 * Commands that are specified for moderators.
                 */
                if (character.ServerRights >= ServerRights.Moderator)
                {
                }

                /*
                 * Commands that are specified for administrators.
                 */
                if (character.ServerRights >= ServerRights.Administrator)
                {
                    #region Teleport

                    /*
                     * Teleports the character to the specified coordinates.
                     */
                    if (command.Equals("teleport"))
                    {
                        if (arguments.Length == 3 || arguments.Length == 4)
                        {
                            short x = short.Parse(arguments[1]);
                            short y = short.Parse(arguments[2]);
                            byte  z = 0;

                            // The character specified a height.
                            if (arguments.Length == 4)
                            {
                                z = byte.Parse(arguments[3]);
                            }
                            character.UpdateFlags.TeleportLocation = Location.Create(x, y, z);
                            character.UpdateFlags.Teleporting      = true;
                        }
                    }
                    #endregion Teleport
                }

                /*
                 * Commands that are specified for system administrators (development).
                 */
                if (character.ServerRights >= ServerRights.SystemAdministrator)
                {
                    #region Animate

                    /*
                     * Plays an animation for the character.
                     */
                    if (command.Equals("animate"))
                    {
                        if (arguments.Length == 2 || arguments.Length == 3)
                        {
                            short id    = short.Parse(arguments[1]);
                            byte  delay = 0;

                            // The character specified a delay.
                            if (arguments.Length == 3)
                            {
                                delay = byte.Parse(arguments[2]);
                            }
                            character.PlayAnimation(Animation.Create(id, delay));
                        }
                    }
                    #endregion Animate

                    #region Graphic

                    /*
                     * Plays a graphic for the character.
                     */
                    else if (command.Equals("graphic"))
                    {
                        if (arguments.Length == 2 || arguments.Length == 3)
                        {
                            short id    = short.Parse(arguments[1]);
                            int   delay = 0;

                            // The character specified a delay.
                            if (arguments.Length == 3)
                            {
                                delay = int.Parse(arguments[2]);
                            }
                            character.PlayGraphics(Graphic.Create(id, delay));
                        }
                    }
                    #endregion Graphic

                    #region Coords

                    /*
                     * Prints out the character's current coordinates.
                     */
                    else if (command.Equals("coords"))
                    {
                        byte[] packet = new MessagePacketComposer(
                            "Current X: " + character.Location.X +
                            ", Current Y: " + character.Location.Y +
                            ", Current Z: " + character.Location.Z +
                            ", Area X: " + character.Location.RegionX +
                            ", Area X: " + character.Location.RegionY).Serialize();
                        character.Session.SendData(packet);
                    }
                    #endregion Coords

                    #region Set Energy

                    /*
                     * Sets the character's energy to the specified amount.
                     */
                    else if (command.Equals("setenergy"))
                    {
                        if (arguments.Length == 2)
                        {
                            byte energy = 100;

                            if (byte.TryParse(arguments[1], out energy))
                            {
                                character.WalkingQueue.RunEnergy = energy;
                                character.Session.SendData(new RunEnergyPacketComposer(energy).Serialize());
                            }
                        }
                        else
                        {
                            character.WalkingQueue.RunEnergy = 100;
                            character.Session.SendData(new RunEnergyPacketComposer(100).Serialize());
                        }
                    }
                    #endregion Set Energy

                    #region Update

                    /*
                     * Sends a system update to all characters online,
                     * and locks out any logins untill server restarts.
                     */
                    else if (command.Equals("update"))
                    {
                        if (arguments.Length == 2 || arguments.Length == 3)
                        {
                            short time    = short.Parse(arguments[1]);
                            bool  restart = false;

                            if (arguments.Length == 3)
                            {
                                restart = bool.Parse(arguments[2]);
                            }
                            Frames.SendSystemUpdate(time, restart);
                        }
                    }
                    #endregion Update

                    else if (command.Equals("show"))
                    {
                        Frames.SendInterface(character, 335, false);
                        for (short i = 0; i < 88; i++)
                        {
                            character.Session.SendData(new StringPacketComposer(i.ToString(), 335, i).Serialize());
                        }
                    }

                    else if (command.Equals("object"))
                    {
                        new MapObject(2, 10, 1, character.Location).Spawn(character);
                    }
                }
            }
            catch (FormatException)
            {
            }
            catch (OverflowException)
            {
            }
            catch (Exception ex)
            {
                Program.Logger.WriteException(ex);
            }
        }