Ejemplo n.º 1
0
    private void SetEquippedWeaponInSlot(WeaponIdentifier weaponIdentifer)
    {
        WeaponPath weaponPath = WeaponPaths[(int)weaponIdentifer];

        Slots[weaponPath.SlotIndex].EquippedWeaponCounter = weaponPath.WeaponIndex;
        CurrentSlot = weaponPath.SlotIndex;
    }
Ejemplo n.º 2
0
    public void AddEquippedWeapon(WeaponIdentifier weaponIdentifier)
    {
        WeaponPath weaponPath = WeaponPaths[(int)weaponIdentifier];

        if (weaponPath != null)
        {
            Slots[weaponPath.SlotIndex].EquippedWeaponCounter = weaponPath.WeaponIndex;
        }
    }
Ejemplo n.º 3
0
        public void Should_Parse_Weapon_Details(string rawPath, string fullMatch, string weaponName, string slot, string type, string path)
        {
            var parsed = WeaponIdentifier.TryParse(rawPath, out var ident);

            Assert.True(parsed);
            Assert.Equal(ident.RawValue, fullMatch);
            Assert.Equal(ident.Weapon, weaponName);
            Assert.Equal(ident.BaseObjectName, weaponName);
            Assert.Equal(ident.Type, type);
            Assert.Equal(ident.ObjectPath, path);
        }
Ejemplo n.º 4
0
    //////////////////////////////////////////////////////////////

    // Weapon activation
    public void ActivateWeapon(WeaponIdentifier weaponIdentifier)
    {
        WeaponPath weaponPath = WeaponPaths[(int)weaponIdentifier];

        if (weaponPath != null)
        {
            GetCurrentWeapon().gameObject.SetActive(false);

            SetCurrentWeapon(weaponIdentifier);
            SetEquippedWeaponInSlot(weaponIdentifier);
            GetCurrentWeapon().gameObject.SetActive(true);

            UpdateCharacterHands(_avatar.Characters[_avatar.CharacterId]);
        }
    }
Ejemplo n.º 5
0
    private void ActivateSlot(int slot)
    {
        if (slot < 0 || slot > Slots.Count - 1)
        {
            return;
        }
        if (!Slots[slot].HasEquippedWeapon())
        {
            return;
        }

        WeaponIdentifier activeWeaponIdentifier = Slots[slot].GetEquippedWeapon().Identifier;

        ActivateWeapon(activeWeaponIdentifier);
    }
Ejemplo n.º 6
0
    private void BuildWeaponPaths()
    {
        int weaponCount = Enum.GetNames(typeof(WeaponIdentifier)).Length;

        WeaponPaths = new WeaponPath[weaponCount];

        for (int slotCounter = 0; slotCounter < Slots.Count; slotCounter++)
        {
            WeaponSlot weaponSlot = Slots[slotCounter];
            for (int weaponCounter = 0; weaponCounter < weaponSlot.Weapons.Count; weaponCounter++)
            {
                WeaponIdentifier weaponIndentifier = weaponSlot.Weapons[weaponCounter].Identifier;
                WeaponPaths[(int)weaponIndentifier] = new WeaponPath(slotCounter, weaponCounter);
            }
        }
    }
        /// <summary>
        /// Create new weapon by properties.
        /// </summary>
        private static GameObject CreateFPWeapon(WeaponProperties properties)
        {
            // Initialize gameobjects.
            GameObject weapon = GameObject.Instantiate <GameObject>(properties.GetWeapon(), Vector3.zero, Quaternion.identity);

            weapon.name  = properties.GetName();
            weapon.tag   = TNC.WEAPON;
            weapon.layer = LayerMask.NameToLayer(LNC.WEAPON);
            for (int i = 0, length = weapon.transform.childCount; i < length; i++)
            {
                weapon.transform.GetChild(i).gameObject.layer = LayerMask.NameToLayer(LNC.WEAPON);
            }

            // Initialize weapon components.
            Animator              animator              = UEditorInternal.AddComponent <Animator>(weapon);
            WeaponIdentifier      weaponIdentifier      = UEditorInternal.AddComponent <WeaponIdentifier>(weapon);
            WeaponAnimationSystem weaponAnimationSystem = UEditorInternal.AddComponent <WeaponAnimationSystem>(weapon);

            switch (properties.GetWeaponType())
            {
            case WeaponProperties.Type.Gun:
            {
                WeaponShootingSystem weaponShootingSystem = UEditorInternal.AddComponent <WeaponShootingSystem>(weapon);
                WeaponReloadSystem   weaponReloadSystem   = UEditorInternal.AddComponent <WeaponReloadSystem>(weapon);
                break;
            }

            case WeaponProperties.Type.Melee:
            {
                WeaponMeleeSystem weaponMeleeSystem = UEditorInternal.AddComponent <WeaponMeleeSystem>(weapon);
                break;
            }

            case WeaponProperties.Type.Throw:
            {
                ThrowingWeaponSystem throwingWeaponSystem = UEditorInternal.AddComponent <ThrowingWeaponSystem>(weapon);
                WeaponReloadSystem   weaponReloadSystem   = UEditorInternal.AddComponent <WeaponReloadSystem>(weapon);
                break;
            }
            }
            AudioSource audioSource = UEditorInternal.AddComponent <AudioSource>(weapon);

            // Setup Animator component.
            if (properties.GetController() != null)
            {
                animator.runtimeAnimatorController = properties.GetController();
            }

            // Setup WeaponID component.
            if (properties.GetWeaponID() != null)
            {
                weaponIdentifier.SetWeapon(properties.GetWeaponID());
            }

            // Apply components position.
            UEditorInternal.MoveComponentBottom <Animator>(weapon.transform);
            UEditorInternal.MoveComponentBottom <WeaponIdentifier>(weapon.transform);
            UEditorInternal.MoveComponentBottom <WeaponAnimationSystem>(weapon.transform);
            switch (properties.GetWeaponType())
            {
            case WeaponProperties.Type.Gun:
            {
                UEditorInternal.MoveComponentBottom <WeaponShootingSystem>(weapon.transform);
                UEditorInternal.MoveComponentBottom <WeaponReloadSystem>(weapon.transform);
                break;
            }

            case WeaponProperties.Type.Melee:
            {
                UEditorInternal.MoveComponentBottom <WeaponMeleeSystem>(weapon.transform);
                break;
            }

            case WeaponProperties.Type.Throw:
            {
                UEditorInternal.MoveComponentBottom <ThrowingWeaponSystem>(weapon.transform);
                UEditorInternal.MoveComponentBottom <WeaponReloadSystem>(weapon.transform);
                break;
            }
            }
            for (int i = 0, length = additionalComponents.Count; i < length; i++)
            {
                AdditionalComponents component = additionalComponents[i];
                if (component.isActive)
                {
                    weapon.AddComponent(component.component);
                }
            }
            UEditorInternal.MoveComponentBottom <AudioSource>(weapon.transform);

            return(weapon);
        }
Ejemplo n.º 8
0
 private void SetCurrentWeapon(WeaponIdentifier weaponIdentifier)
 {
     CurrentWeapon = weaponIdentifier;
 }
Ejemplo n.º 9
0
    private void EquipPlayerWithWeapon(GameObject player, WeaponIdentifier weaponIdentifier)
    {
        F3DWeaponController playerWeaponController = player.GetComponent <F3DWeaponController>();

        playerWeaponController.AddEquippedWeapon(weaponIdentifier);
    }