Esempio n. 1
0
 public static void UnlockWeaponEvent(WeaponType wt, Player __instance)
 {
     if (MenuManager.opt_primary_autoswitch == 0 && MPAutoSelection.primarySwapFlag)
     {
         if (GameplayManager.IsMultiplayerActive && NetworkMatch.InGameplay() && __instance == GameManager.m_local_player)
         {
             int new_weapon     = getWeaponPriority(wt);
             int current_weapon = getWeaponPriority(GameManager.m_local_player.m_weapon_type);
             if (!PrimaryNeverSelect[new_weapon] && (new_weapon < current_weapon ||
                                                     (MPClassic.matchEnabled && GameManager.m_local_player.m_weapon_type.Equals(WeaponType.IMPULSE) && GameManager.m_local_player.m_weapon_level[0].Equals(WeaponUnlock.LEVEL_1)) // Specific impulse upgrade case for classic mod
                                                     ))
             {
                 if (!Controls.IsPressed(CCInput.FIRE_WEAPON))
                 {
                     swapToWeapon(wt.ToString());
                     GameManager.m_local_player.UpdateCurrentWeaponName();
                 }
                 else
                 {
                     waitingSwapWeaponType = wt.ToString();
                 }
             }
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Initialize when object is recognized as a network-object-
        /// </summary>
        public override void Attached()
        {
            if (!entity.IsOwner)
            {
                return;
            }

            state.WeaponName   = weaponType.ToString();
            state.WeaponAmount = amount;
        }
Esempio n. 3
0
        public void ChangeCurrentWeapon(WeaponType weapon, byte upgrades)
        {
            currentWeapon = weapon;

            if ((upgrades & 0x1) != 0)
            {
                switch (weapon)
                {
                case WeaponType.Blaster:
                    if (owner.PlayerType == PlayerType.Spaz)
                    {
                        currentWeaponString = "WeaponPowerUpBlasterSpaz";
                    }
                    else if (owner.PlayerType == PlayerType.Lori)
                    {
                        currentWeaponString = "WeaponPowerUpBlasterLori";
                    }
                    else
                    {
                        currentWeaponString = "WeaponPowerUpBlasterJazz";
                    }
                    break;

                default:
                    currentWeaponString = "WeaponPowerUp" + weapon.ToString("G");
                    break;
                }
            }
            else
            {
                switch (weapon)
                {
                case WeaponType.Blaster:
                    if (owner.PlayerType == PlayerType.Spaz)
                    {
                        currentWeaponString = "WeaponBlasterSpaz";
                    }
                    else if (owner.PlayerType == PlayerType.Lori)
                    {
                        currentWeaponString = "WeaponBlasterLori";
                    }
                    else
                    {
                        currentWeaponString = "WeaponBlasterJazz";
                    }
                    break;

                default:
                    currentWeaponString = "Weapon" + weapon.ToString("G");
                    break;
                }
            }
        }
Esempio n. 4
0
    public void RemoveWeapon(WeaponType weapon)
    {
        Debug.Log("Remove weapon of type: " + weapon.ToString());
        Weapon weaponInstance;
        bool   hasWeapon = currentWeapons.TryGetValue(weapon, out weaponInstance);

        if (hasWeapon)
        {
            Debug.Log("Found weapon of type to remove: " + weapon.ToString());
            weaponInstance.Die();
            currentWeapons.Remove(weapon);
            Destroy(weaponInstance);
        }
    }
Esempio n. 5
0
        public Weapon(WeaponType weaponType)
        {
            if (Weapons.ContainsKey(weaponType))
            {
                initialize(Weapons[weaponType]);
            }
            else
            {
                string fileName = Program.rootPath + "Data/" + weaponType.ToString() + ".gat";
                DataContractSerializer serializer = new DataContractSerializer(typeof(Weapon));

                if (File.Exists(fileName))
                {
                    using (XmlReader xr = XmlReader.Create(fileName))
                    {
                        Weapon templateWeapon = (Weapon)serializer.ReadObject(XmlReader.Create(fileName));
                        initialize(templateWeapon);
                    }
                }
                else
                {
                    initialize();
                    using (XmlWriter xw = XmlWriter.Create(fileName))
                    {
                        serializer.WriteObject(xw, this);
                    }
                }
                Weapons[weaponType] = this;
            }
        }
Esempio n. 6
0
 public Weapon(WeaponType type, WeaponAttribute attribute)
 {
     weapon         = type;
     this.attribute = attribute;
     name           = attribute.ToString() + " " + weapon.ToString();
     setWeaponRoll();
 }
Esempio n. 7
0
    void WeaponChange()
    {
        var inpV = Input.GetAxisRaw("Vertical");

        if (!_isWeapon)
        {
            if (Mathf.Abs(inpV) > 0.2f)
            {
                _isWeapon = true;
                if (inpV > 0.5f)
                {
                    _wNum--;
                }
                else
                {
                    _wNum++;
                }
                if (_wNum >= _weapon.Size())
                {
                    _wNum = 0;
                }
                else if (_wNum < -0.5f)
                {
                    _wNum = _weapon.Size() - 1;
                }
            }
        }
        _weapon          = (WeaponType)_wNum;
        _weaponText.text = _weapon.ToString();
        if (inpV < 0.1f && inpV > -0.1f)
        {
            _isWeapon = false;
        }
    }
Esempio n. 8
0
        /// <summary>
        /// Load a skeleton game object from resources prefab
        /// </summary>
        /// <param name="gender"></param>
        /// <param name="weapon"></param>
        /// <returns></returns>
        public GameObject loadSkeleton(GenderType gender, WeaponType weapon)
        {
            var prefab = Resources.Load("Animation/" + gender.ToString() + "/" + weapon.ToString() + "/skeleton");
            var clone  = GameObject.Instantiate(prefab);

            return(clone as GameObject);
        }
Esempio n. 9
0
 //Function that takes in the current weapon the player has, the positon of the weaponDrop they are picking up, and game objects for all the different weapons
 //It then creates a Weapon drop for the current weapon the player has and destorys the one in the players hand.
 //TODO: To make this universal must find a way to do something other than pass in every concevable weapon type. there has to be a better way
 public void DestroyCurrentCreateDrop(WeaponType currentWeapon, float loadedAmmo, float totalAmmo, Transform weaponDrop)
 {
     if (currentWeapon == WeaponType.HandGun)
     {
         Instantiate(HandGunDrop, weaponDrop.transform.position, weaponDrop.transform.rotation);
         SetDropAttributes(currentWeapon, weaponDrop.transform.position, player.GetComponent <PlayerController>().loadedAmmo, player.GetComponent <PlayerController>().totalAmmo);
     }
     else if (currentWeapon == WeaponType.Rifle)
     {
         Instantiate(RifleDrop, weaponDrop.transform.position, weaponDrop.transform.rotation);
         SetDropAttributes(currentWeapon, weaponDrop.transform.position, player.GetComponent <PlayerController>().loadedAmmo, player.GetComponent <PlayerController>().totalAmmo);
     }
     if (currentWeapon == WeaponType.Shotgun)
     {
         Instantiate(ShotgunDrop, weaponDrop.transform.position, weaponDrop.transform.rotation);
         SetDropAttributes(currentWeapon, weaponDrop.transform.position, player.GetComponent <PlayerController>().loadedAmmo, player.GetComponent <PlayerController>().totalAmmo);
     }
     if (currentWeapon == WeaponType.RocketLauncher)
     {
         Instantiate(RocketLauncherDrop, weaponDrop.transform.position, weaponDrop.transform.rotation);
         SetDropAttributes(currentWeapon, weaponDrop.transform.position, player.GetComponent <PlayerController>().loadedAmmo, player.GetComponent <PlayerController>().totalAmmo);
     }
     if (currentWeapon == WeaponType.Sword)
     {
         Instantiate(SwordDrop, weaponDrop.transform.position, weaponDrop.transform.rotation);
         SetDropAttributes(currentWeapon, weaponDrop.transform.position, player.GetComponent <PlayerController>().loadedAmmo, player.GetComponent <PlayerController>().totalAmmo);
     }
     if (currentWeapon == WeaponType.Axe)
     {
         Instantiate(AxeDrop, weaponDrop.transform.position, weaponDrop.transform.rotation);
         SetDropAttributes(currentWeapon, weaponDrop.transform.position, player.GetComponent <PlayerController>().loadedAmmo, player.GetComponent <PlayerController>().totalAmmo);
     }
     Destroy(GameObject.FindGameObjectWithTag(currentWeapon.ToString()));
 }
Esempio n. 10
0
        private void HandlePlayerWeaponSwitch()
        {
            int weaponIndex = -1;

            if (Input.IsActionJustPressed(SceneControls.PlayerWeaponSwitch_1))
            {
                weaponIndex = 0;
            }
            else if (Input.IsActionJustPressed(SceneControls.PlayerWeaponSwitch_2))
            {
                weaponIndex = 1;
            }
            else if (Input.IsActionJustPressed(SceneControls.PlayerWeaponSwitch_3))
            {
                weaponIndex = 2;
            }

            if (weaponIndex != -1)
            {
                WeaponType  weaponType  = (WeaponType)weaponIndex;
                WeaponState weaponState = _playerWeapons[weaponType];

                if (weaponState.isUnlocked)
                {
                    _currentWeaponType = weaponType;
                }
                else
                {
                    DialogueUiManager.instance.DisplaySingleStringTimed($"{weaponType.ToString()} weapon not yet owned", weaponLockedErrorDisplayTime);
                }
            }
        }
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                type = WeaponType.Pistol;
                ChangeWeapon(type);
                weaponText.UpdateText(type.ToString());
            }
            else if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                type = WeaponType.GravityGun;
                ChangeWeapon(type);
                weaponText.UpdateText(type.ToString());
            }
            else if (Input.GetKeyDown(KeyCode.Alpha3))
            {
                type = WeaponType.GrappleGun;
                ChangeWeapon(type);
                weaponText.UpdateText(type.ToString());
            }

            //if (Input.GetKeyDown(KeyCode.Alpha1))
            //{
            //    LoopLeft();

            //    UpdateGun();
            //}
            //else if (Input.GetKeyDown(KeyCode.Alpha2))
            //{
            //    LoopRight();

            //    UpdateGun();
            //}
        }
Esempio n. 12
0
        public static int getWeaponPriority(WeaponType primary)
        {
            if (MPAutoSelection.isInitialised)
            {
                string wea = primary.ToString();

                for (int i = 0; i < 8; i++)
                {
                    if (wea.Equals(PrimaryPriorityArray[i]))
                    {
                        return(i);
                    }
                    if (wea.Equals("CRUSHER") && PrimaryPriorityArray[i].Equals("CRUSHER"))
                    {
                        return(i);
                    }
                }
                uConsole.Log("-AUTOSELECT- [WARN]: getWeaponPriority:-1, primary wasnt in array");
                return(-1);
            }
            else
            {
                uConsole.Log("-AUTOSELECT- [WARN]: getWeaponPriority:-1, priority didnt get initialised");
                return(-1);
            }
        }
Esempio n. 13
0
 void Update()
 {
     if (Input.GetButton("Fire2"))
     {
         Debug.Log("Boom! I just fired my " + activeWeapon.ToString());
     }
 }
    public void Initialize()
    {
        _animationEndPlay = false;
        changeAmmo?.Invoke(currentAmmo, maxAmmo, ammoName);

        Debug.Log("Initialize from " + typeWeapon.ToString());
    }
Esempio n. 15
0
        protected override async Task OnActivatedAsync(ActorActivationDetails details)
        {
            weaponType = (WeaponType)details.Params[0];

            Movable = true;

            collisionFlags |= CollisionFlags.SkipPerPixelCollisions;

            await RequestMetadataAsync("Object/PowerUpMonitor");

            switch (weaponType)
            {
            case WeaponType.Blaster:
                PlayerType player = (api.Players.Count == 0 ? PlayerType.Jazz : api.Players[0].PlayerType);
                if (player == PlayerType.Spaz)
                {
                    SetAnimation("BlasterSpaz");
                }
                else if (player == PlayerType.Lori)
                {
                    SetAnimation("BlasterLori");
                }
                else
                {
                    SetAnimation("BlasterJazz");
                }
                break;

            default: SetAnimation(weaponType.ToString("G")); break;
            }
        }
Esempio n. 16
0
        public override string ToJson()
        {
            if (SpriteCollection == null)
            {
                throw new Exception("SpriteCollection is not set!");
            }

            var description = new Dictionary <string, string>
            {
                { "Head", SpriteToString(SpriteCollection.Head, HeadRenderer) },
                { "Body", SpriteToString(SpriteCollection.Body, BodyRenderers[0]) },
                { "Ears", SpriteToString(SpriteCollection.Ears, EarsRenderer) },
                { "Hair", SpriteToString(SpriteCollection.Hair, HairRenderer) },
                { "Beard", SpriteToString(SpriteCollection.Beard, BeardRenderer) },
                { "Helmet", SpriteToString(SpriteCollection.Helmet, HelmetRenderer) },
                { "Glasses", SpriteToString(SpriteCollection.Glasses, GlassesRenderer) },
                { "Mask", SpriteToString(SpriteCollection.Mask, MaskRenderer) },
                { "Cape", SpriteToString(SpriteCollection.Cape, CapeRenderer) },
                { "Back", SpriteToString(SpriteCollection.Back, BackRenderer) },
                { "Shield", SpriteToString(SpriteCollection.Shield, ShieldRenderer) },
                { "WeaponType", WeaponType.ToString() },
                { "Expression", Expression },
                { "BodyScaleX", BodyScale.x.ToString(CultureInfo.InvariantCulture) },
                { "BodyScaleY", BodyScale.y.ToString(CultureInfo.InvariantCulture) }
            };

            switch (WeaponType)
            {
            case WeaponType.Melee1H:
            case WeaponType.Melee2H:
            case WeaponType.MeleePaired:
                description.Add("PrimaryMeleeWeapon", SpriteToString(GetWeaponCollection(WeaponType), PrimaryMeleeWeaponRenderer));
                description.Add("SecondaryMeleeWeapon", SpriteToString(GetWeaponCollection(WeaponType), SecondaryMeleeWeaponRenderer));
                break;

            case WeaponType.Bow:
                description.Add("Bow", SpriteToString(SpriteCollection.Bow, BowRenderers[0]));
                break;

            case WeaponType.Firearms1H:
            case WeaponType.Firearms2H:
                description.Add("Firearms", SpriteToString(GetWeaponCollection(WeaponType), FirearmsRenderers[0]));
                description.Add("FirearmParams", Firearm.Params.Name);
                break;
            }

            for (var i = 0; i < ArmorRenderers.Count; i++)
            {
                description.Add($"Armor[{i}]", SpriteToString(SpriteCollection.Armor, ArmorRenderers[i]));
            }

            foreach (var expression in Expressions)
            {
                description.Add($"Expression.{expression.Name}.Eyebrows", SpriteToString(SpriteCollection.Eyebrows, expression.Eyebrows, EyebrowsRenderer.color));
                description.Add($"Expression.{expression.Name}.Eyes", SpriteToString(SpriteCollection.Eyes, expression.Eyes, EyesRenderer.color));
                description.Add($"Expression.{expression.Name}.Mouth", SpriteToString(SpriteCollection.Mouth, expression.Mouth, MouthRenderer.color));
            }

            return(JsonConvert.SerializeObject(description));
        }
    /// <summary>
    /// NPC 스포너에서 n초간 대기 후 본 함수를 호출해 해당 NPC를 획득 및 스포너 삭제
    /// </summary>
    public void GetNpcFromSpawner()
    {
        // npc 신규 탑승
        if (GameObject.FindGameObjectWithTag("Player").GetComponent <NPCTaker>().seat[(int)type].childCount == 0)
        {
            // 타겟 NPC 로드 - # 경로 주의 #
            var v = Resources.Load("Prefabs/Objects/NPCs/NPC_" + type.ToString());

            GameObject npc = Instantiate((GameObject)v);
            npc.GetComponentInChildren <NPCInfo>().SitOnTruck();

            npc.transform.parent        = GameObject.FindGameObjectWithTag("Player").GetComponent <NPCTaker>().seat[(int)type];
            npc.transform.localPosition = Vector3.zero;

            PlayerUIManager.instance.AddNpc(type, 1, npc.transform);
        }

        // 이미 탑승해 있는 npc.
        // 해당 npc 업그레이드
        else
        {
            int lv = GameObject.FindGameObjectWithTag("Player").GetComponent <NPCTaker>().seat[(int)type].GetChild(0)
                     .GetComponentInChildren <AssultController>().LevelUp();

            PlayerUIManager.instance.AddNpc(type, lv);
        }

        // 자신 npc 스포너 삭제
        Destroy(gameObject);
    }
Esempio n. 18
0
        public override void OnAttach(ActorInstantiationDetails details)
        {
            base.OnAttach(details);

            weaponType = (WeaponType)details.Params[0];

            Movable = true;

            collisionFlags |= CollisionFlags.SkipPerPixelCollisions;

            RequestMetadata("Object/PowerUpMonitor");

            switch (weaponType)
            {
            case WeaponType.Blaster:
                PlayerType player = (api.Players.Count == 0 ? PlayerType.Jazz : api.Players[0].PlayerType);
                if (player == PlayerType.Spaz)
                {
                    SetAnimation("BlasterSpaz");
                }
                else if (player == PlayerType.Lori)
                {
                    SetAnimation("BlasterLori");
                }
                else
                {
                    SetAnimation("BlasterJazz");
                }
                break;

            default: SetAnimation(weaponType.ToString("G")); break;
            }
        }
    /// <summary>
    /// Determines whether player is able to craft anything given entered materials
    /// </summary>
    /// <param name="materialsOnDeck">array of materials in crafting menu</param>
    public void DetermineItemFromMaterials(CraftingMaterials[] materialsOnDeck)
    {
        // search registry for crafted weapon
        WeaponType craftedType = CraftableItemsRegistry.GetCraftableItem(materialsOnDeck);

        // if search yielded anything (i.e., not pistol as that is never craftable)
        if (craftedType != WeaponType.Pistol)
        {
            // set current craftable weapon to one retrieved from registry
            currCraftableWeapon = craftedType;

            // show appropriate craftable weapon on menu
            craftedItemImage.sprite  = craftedWeaponIcons[(int)craftedType];
            craftedItemImage.color   = new Color(craftedItemImage.color.r, craftedItemImage.color.g, craftedItemImage.color.b, 1);
            craftedItemNameText.text = craftedType.ToString();

            // set craft button to interactable
            craftButton.interactable = true;

            // play higher pitched push sound
            AudioManager.Play(AudioClipNames.UI_pushLastMaterial, true);
        }
        // otherwise (user didn't enter good combination)
        else
        {
            // play denied sound effect
            AudioManager.Play(AudioClipNames.UI_denied, true);
        }
    }
Esempio n. 20
0
        public string GetCurrentWeapon(WeaponType weapon)
        {
            if ((owner.WeaponUpgrades[(int)weapon] & 0x1) != 0)
            {
                switch (weapon)
                {
                case WeaponType.Blaster:
                    if (owner.PlayerType == PlayerType.Spaz)
                    {
                        return("WeaponPowerUpBlasterSpaz");
                    }
                    else if (owner.PlayerType == PlayerType.Lori)
                    {
                        return("WeaponPowerUpBlasterLori");
                    }
                    else
                    {
                        return("WeaponPowerUpBlasterJazz");
                    }

                default:
                    return("WeaponPowerUp" + weapon.ToString("G"));
                }
            }
            else
            {
                switch (owner.CurrentWeapon)
                {
                case WeaponType.Blaster:
                    if (owner.PlayerType == PlayerType.Spaz)
                    {
                        return("WeaponBlasterSpaz");
                    }
                    else if (owner.PlayerType == PlayerType.Lori)
                    {
                        return("WeaponBlasterLori");
                    }
                    else
                    {
                        return("WeaponBlasterJazz");
                    }

                default:
                    return("Weapon" + weapon.ToString("G"));
                }
            }
        }
Esempio n. 21
0
    public WeaponPrefabPool(WeaponType _type)
    {
        type         = _type;
        poolObjs     = new List <Weapon>();
        AliveObjects = new List <Weapon>();

        prefab = Resources.Load <GameObject>("Prefab/" + _type.ToString());
    }
Esempio n. 22
0
    public void Inititialize(WeaponType weapon)
    {
        weaponType = weapon;

        var components = GetComponentsInChildren <ComponentType>();

        foreach (ComponentType ct in components)
        {
            if (ct.componentName == "weaponImage")
            {
                Debug.Log("Loading sprite for: " + weapon.ToString());
                Sprite sp       = Resources.Load <Sprite>(weapon.ToString());
                Image  itemSlot = ct.gameObject.GetComponent <Image>();
                itemSlot.sprite = sp;
            }
        }
    }
Esempio n. 23
0
        public Weapon CreateWeapon(WeaponType weaponType)
        {
            Type typeOfWeapon = Assembly.GetExecutingAssembly().
                                GetTypes().FirstOrDefault(a => a.Name == weaponType.ToString());

            Weapon weapon = (Weapon)Activator.CreateInstance(typeOfWeapon);

            return(weapon);
        }
Esempio n. 24
0
    public void WeaponChange()
    {
        WeaponType activeWeapon = PlayerController.instance.weaponManager.currentWeapon.val;

        Debug.Log(string.Format("Change weapon {0}", activeWeapon.ToString()));
        Weapon weapon = GetWeaponTable()[(int)activeWeapon];

        weaponImage.sprite = weapon.icon;
    }
Esempio n. 25
0
    public WeaponBaseAttr GetWeaponBaseAttr(WeaponType weaponType)
    {
        if (!mDic_WeaponBaseAttr.ContainsKey(weaponType))
        {
            Debug.LogError("AttrFactory::无法找到指定类型的武器 ---" + weaponType.ToString());
        }

        return(mDic_WeaponBaseAttr[weaponType]);
    }
Esempio n. 26
0
 private Result BuyRepair(WeaponType repairType)
 {
     if (WeaponTypeMap.ContainsKey(repairType))
     {
         WeaponTypeMap[repairType].CurrentDurability = 100f;
     }
     Debug.Log(repairType.ToString() + " REPAIRED");
     return(Result.Success);
 }
Esempio n. 27
0
 string GetWeaponPrefabPath(WeaponType _type)
 {
     if (mapWeaponPrefabPath.ContainsKey(_type) == false)
     {
         string name = "prefab/" + _type.ToString();
         mapWeaponPrefabPath.Add(_type, name);
     }
     return(mapWeaponPrefabPath[_type]);
 }
Esempio n. 28
0
 public void SetSkill(int slot, Ability skill)
 {
     if (AbilityLibrary.WeaponSupportsSkill(skill.abilityName, type.ToString()))
     {
         skillStringName[slot]   = skill.abilityName;
         SkillSet[slot]          = skill;
         SelectedAbilities[slot] = lib.AbilityDictionary[SkillSet[slot].abilityName].UseAbility;
     }
 }
Esempio n. 29
0
        public Weapon(string name, WeaponType type)
        {
            if (String.IsNullOrEmpty(name))
            {
                name = type.ToString();
            }

            this.Name = name;
            this.Type = type;
        }
Esempio n. 30
0
 // Token: 0x060000CF RID: 207 RVA: 0x0000E344 File Offset: 0x0000C744
 private float GetReachDistance(WeaponType weaponType, SanityType sanityType)
 {
     if (weaponType == WeaponType.Knife)
     {
         if (this.Stealth)
         {
             return(0.75f);
         }
         if (sanityType == SanityType.High)
         {
             return(1f);
         }
         if (sanityType == SanityType.Medium)
         {
             return(0.75f);
         }
         return(0.5f);
     }
     else
     {
         if (weaponType == WeaponType.Katana)
         {
             return((!this.Stealth) ? 1f : 0.5f);
         }
         if (weaponType == WeaponType.Bat)
         {
             if (this.Stealth)
             {
                 return(0.5f);
             }
             if (sanityType == SanityType.High)
             {
                 return(0.75f);
             }
             if (sanityType == SanityType.Medium)
             {
                 return(1f);
             }
             return(1f);
         }
         else
         {
             if (weaponType == WeaponType.Saw)
             {
                 return((!this.Stealth) ? 1f : 0.7f);
             }
             if (weaponType == WeaponType.Syringe)
             {
                 return(0.5f);
             }
             Debug.LogError("Weapon type \"" + weaponType.ToString() + "\" not implemented.");
             return(0f);
         }
     }
 }
Esempio n. 31
0
 public static Weapon GetWeaponPrefab(WeaponType type)
 {
     /*switch (type) {
     case WeaponType.Spear1:
         return Resources.Load("Weapons/Spear1");
         break;
     case WeaponType.Sword1:
         break;
     default:
         Debug.Log("Weapon type '" + type + "' is not implemented");
         break;
     }*/
     GameObject prefab = Resources.Load ("Weapons/" + type.ToString ()) as GameObject;
     GameObject instance = Instantiate (prefab) as GameObject;
     return instance.GetComponent<Weapon> ();
 }
Esempio n. 32
0
    public static Weapon CreateWeapon(WeaponType type, WeaponQuality quality = WeaponQuality.Factory)
    {
        var weapon = new Weapon()
        {
            Guid = Guid.NewGuid(),
            Type = type,
            Quality = quality
        };

        var values = Enum.GetValues(typeof(WeaponType)).Cast<int>();
        var index = Enum.GetNames(typeof(WeaponType)).ToList().IndexOf(type.ToString()); // ugh

        var price = values.ElementAt(index);

        values = Enum.GetValues(typeof(WeaponQuality)).Cast<int>();
        index = Enum.GetNames(typeof(WeaponQuality)).ToList().IndexOf(quality.ToString()); // ugh

        price *= values.ElementAt(index);

        weapon.Price = price;
        weapon.Name = type.ToString();

        return weapon;
    }
Esempio n. 33
0
        /// <summary>
        /// Generate an animation prefab for the given gender and weapon
        /// </summary>
        /// <param name="gender"></param>
        /// <param name="weapon"></param>
        public void GenerateAnimationAsset(GenderType gender, WeaponType weapon)
        {
            GameObject skeleton = new GameObject("skeleton");
            bool male = (gender == GenderType.MALE);
            ZMD zmd = new ZMD( male ? "Assets/3DData/Avatar/MALE.ZMD" : "Assets/3DData/Avatar/FEMALE.ZMD");
            zmd.buildSkeleton(skeleton);

            BindPoses poses = ScriptableObject.CreateInstance<BindPoses> ();
            poses.bindPoses = zmd.bindposes;
            poses.boneNames = getBoneNames (zmd.boneTransforms);
            poses.boneTransforms = zmd.boneTransforms;
            LoadClips(skeleton, zmd, weapon, gender);
            string path = "Assets/Resources/Animation/" + gender.ToString() + "/" + weapon.ToString() + "/skeleton.prefab";
            AssetDatabase.CreateAsset(poses, path.Replace("skeleton.prefab", "bindPoses.asset"));
            AssetDatabase.SaveAssets();
            PrefabUtility.CreatePrefab(path, skeleton);
        }
Esempio n. 34
0
 public InvalidWeaponException(WeaponType weaponType)
     : base("Invalid weapon type: " + weaponType.ToString())
 {
 }
Esempio n. 35
0
 // Create a weapon
 public Weapon(string itemName, WeaponType itemType, Sprite itemIcon, int attack, int cost)
     : base(itemName, itemType.ToString(), itemIcon, attack, 0, 0, 0, cost)
 {
     // Leave empty
 }
Esempio n. 36
0
        /// <summary>
        /// Loads all animations for given weapon type and gender. The clips are saved to Animation/{gender}/{weapon}/clips/{action}.anim 
        /// Used only in editor to generate prefabs
        /// </summary>
        /// <param name="skeleton"></param>
        /// <param name="weapon"></param>
        /// <param name="gender"></param>
        /// <returns></returns>
        public void LoadClips(GameObject skeleton, ZMD zmd, WeaponType weapon, GenderType gender)
        {
            List<AnimationClip> clips = new List<AnimationClip>();

            foreach (ActionType action in Enum.GetValues(typeof(ActionType)))
            {
                string zmoPath = Utils.FixPath(ResourceManager.Instance.GetZMOPath(weapon, action, gender));  // Assets/3ddata path
                string unityPath = "Assets/Resources/Animation/" + gender.ToString() + "/" + weapon.ToString() + "/clips/" + action.ToString() + ".anim";

                AnimationClip clip =  new ZMO("Assets/" + zmoPath).buildAnimationClip(zmd);
                clip.name = action.ToString();
                clip.legacy = true;
                clip = (AnimationClip)Utils.SaveReloadAsset(clip, unityPath, ".anim");
                clips.Add(clip);
            }

            Animation animation = skeleton.AddComponent<Animation> ();
            AnimationUtility.SetAnimationClips(animation, clips.ToArray());
        }
Esempio n. 37
0
 /// <summary>
 /// Load bindposes and bones matrices from resources scriptable object
 /// </summary>
 /// <param name="gender"></param>
 /// <param name="weapon"></param>
 /// <returns></returns>
 public BindPoses loadBindPoses(GameObject skeleton, GenderType gender, WeaponType weapon)
 {
     BindPoses poses =  ScriptableObject.Instantiate<BindPoses>((BindPoses)Resources.Load ("Animation/" + gender.ToString () + "/" + weapon.ToString () + "/bindPoses"));
     for (int i = 0; i < poses.boneNames.Length; i++) {
         poses.boneTransforms[i] = Utils.findChild(skeleton, poses.boneNames[i]);
     }
     return poses;
 }
Esempio n. 38
0
 /// <summary>
 /// Load a skeleton game object from resources prefab
 /// </summary>
 /// <param name="gender"></param>
 /// <param name="weapon"></param>
 /// <returns></returns>
 public GameObject loadSkeleton(GenderType gender, WeaponType weapon)
 {
     var prefab = Resources.Load ("Animation/" + gender.ToString () + "/" + weapon.ToString () + "/skeleton");
     var clone =  GameObject.Instantiate ( prefab );
     return clone as GameObject;
 }