Example #1
0
 void Start()
 {
     GunType gun = new GunType();
     gun.bullet = (GameObject)Resources.Load("Bullet/Prefab/bullet1");
     gun.GunName = "Gun1";
     gun.AddGun();
     anim = GetComponent<Animator>();
 }
Example #2
0
        //attachments, weapon xp, ...
        public Firearm(int x, int y, int z, String name, String desc, char displaychar, double weight, Caliber cal, GunType type, List<FireMode> modes, int mag_cap)
            : base(x,y,z,name,desc,displaychar, weight, EquipmentSlot.Ranged)
        {
            caliber = cal;
            this.type = type;
            this.modes = new List<FireMode>(modes);
            this.mode = modes[0];

            MagazineCapacity = mag_cap;
        }
Example #3
0
 public Monster(Monster m)
 {
     name = m.name;
     id = m.id;
     position = m.position;
     up = m.up;
     fixedPath = m.fixedPath;
     waypointId = m.waypointId;
     movement = m.movement;
     armor = m.armor;
     weapon = m.weapon;
     behavior = m.behavior;
 }
Example #4
0
 public void InstanciateGun(NetworkViewID id,int gt)
 {
     gunType = (GunType)gt;
     var o = Instantiate(_Game.playerPrefab.GetComponent<Player>().guns[(int)gunType], cursor.transform.position, Quaternion.identity);        
     gun = (Gun)o;
     gun.networkView.viewID = id;
     gun.player = null;
     gun.OwnerID = OwnerID;
     gun.transform.parent = this.cursor.transform;
     gun.EnableGun();
     
     SetLayer(gameObject);
 }
Example #5
0
        public Inventory(uint red, uint green, uint blue, uint yellow, InvType type, string key)
        {
            _type = type;
            if (type == InvType.Turret)
            {
                WHITE = new Gun(-1, 200, 1, "WhiteBullet", InvType.Turret);
                _CurrentGunType = GunType.WHITE;
            }
            else if (type == InvType.Player)
            {
                RED = new Gun((int)red, 100, 1, "RedBullet", InvType.Player, Vector2.UnitY, -Vector2.UnitY * 3);
                GREEN = new Gun((int)green, 200, 1, "GreenBullet", InvType.Player, Vector2.UnitY, -Vector2.UnitY * 3);
                BLUE = new Gun((int)blue, 300, 1, "BlueBullet", InvType.Player, Vector2.UnitY, -Vector2.UnitY * 3);
                WHITE = new Gun(-1, 200, 1, "WhiteBullet", InvType.Player, Vector2.UnitY, -Vector2.UnitY * 3);

                _CurrentGunType = GunType.WHITE;
                YELLOW = yellow;
            }
            else if (type == InvType.Gunner)
            {
                List<Vector2> offsets = new List<Vector2>();

                switch (key)
                {
                    case "graybulbwithsidegunthings":
                        offsets.Add(new Vector2(0, -12));
                        offsets.Add(new Vector2(0, 8));
                        break;

                    case "blueshipwithbulb":
                        offsets.Add(new Vector2(0, -10));
                        offsets.Add(new Vector2(0, 8));
                        break;

                    case "browntriangleship":
                        offsets.Add(new Vector2(0, -10));
                        offsets.Add(new Vector2(0, 7));
                        break;
                }

                WHITE = new Gun(-1, 1000, 1, "EnemyBullet", InvType.Gunner, offsets.ToArray());
                _CurrentGunType = GunType.WHITE;
            }
            else if (type == InvType.Cannon)
            {
                WHITE = new Gun(-1, 2500, 1, "", InvType.Cannon, new Vector2[] { });
                _CurrentGunType = GunType.WHITE;
            }
        }
 public Bullet(float _x, float _y, GunType type, int _xDir, int _yDir=0)
 {
     x = _x;
     y = _y;
     xDir = _xDir;
     yDir = _yDir;
     if (type == GunType.HandGun) {
         speed = 300;
         hitPoints = 10;
         hitPointSpeed = -0.7f;
         width = 5;
         height = 2;
         graphic = new Graphic (Color.Black, width, height);
     }
 }
Example #7
0
    public void GotLoot(GunType type, int ammo)
    {
        foreach(var gun in m_activeGuns) {
            if(gun.m_type == type) {
                if(gun.m_ammo != -1) {
                    gun.m_ammo += ammo;
                }
                return;
            }
        }

        DisableGun (m_currentIndex);
        AddGunToList(type);
        m_currentIndex = m_activeGuns.Count - 1;
        EnableGun (m_currentIndex);
    }
Example #8
0
    void SwitchGuns(GunTypeEnum gunTypeEnum)
    {
        currentGunType = gunTypeEnum;

        if (gunTypeEnum == GunTypeEnum.Rifle)
        {
            gunType = new Rifle();
        }
        else
        {
            gunType = new Shotgun();
        }
        gunType.Initialize(gameObject);
        mySpriteRenderer.sprite = gunType.GetSprite();

        shotFrequency = gunType.GetShotFrequency();
        shotTimer = 0.0f;
    }
Example #9
0
 public static void AddGun(this GunType gun)
 {
     if (!string.IsNullOrEmpty(gun.GunName))
     {
         if (!Guns.Exists(x => x.GunName == gun.GunName))
         {
             Guns.Add(gun);
         }
         else
         {
             Guns.First(x => x.GunName == gun.GunName).bulletCount += gun.bulletCount;
         }
         if (CurrentGun == null && Guns.Count > 0)
         {
             CurrentGun = Guns.First();
         }
     }
 }
Example #10
0
        public GunSlot[] GetUserGuns(string name, Ship s)
        {
            GunSlot[] gs     = null;
            byte      gunNum = 0;

            try
            {
                reader = XmlReader.Create("world\\players\\" + name + ".xml");
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.Name)
                        {
                        case "Count":
                        {
                            reader.Read();
                            gs = new GunSlot[int.Parse(reader.Value)];
                        }
                        break;

                        case "GunType":
                        {
                            reader.Read();
                            GunType gt = (GunType)byte.Parse(reader.Value);
                            gs[gunNum] = new GunSlot(gt, s);
                            gunNum++;
                        }
                        break;
                        }
                    }
                }
                reader.Close();
                return(gs);
            }
            catch
            {
                if (reader != null)
                {
                    reader.Close();
                }
                return(null);
            }
        }
Example #11
0
    override public void injure(int hp, GunType gun, Collider collider)
    {
        if (this.isDead)
        {
            return;
        }

        base.injure(hp, gun, collider);

        if (isDead)
        {
            transform.GetChild(0).GetComponent <Animator>().SetBool("isDead", true);
            GetComponent <Animator>().speed = 0;
        }
        else
        {
            transform.GetChild(0).GetComponent <Animator>().SetTrigger("isHurt");
        }
    }
Example #12
0
    /// <summary>
    /// 获取当前拥有的所有枪类型,当前装备的枪类型
    /// </summary>
    /// <param name="AllGunType">所有枪类型</param>
    /// <param name="CurrentGunType">当前枪类型</param>
    public void GetAllGunTypeAndCurrentGunType(out GunType[] AllGunType, out GunType[] CurrentGunType)
    {
        AllGunType = new GunType[6];
        for (int i = 0; i < AllGunType.Length; i++)
        {
            AllGunType[i] = GunType.Null;
        }
        foreach (GunType gunType in GunTypePossession)
        {
            AllGunType[(int)gunType] = gunType;
        }

        CurrentGunType = new GunType[4];
        for (int i = 0; i < 3; i++)
        {
            CurrentGunType[i] = LeftGunType[i];
        }
        CurrentGunType[3] = RightGunType;
    }
Example #13
0
    public void GotLoot(GunType type, int ammo)
    {
        foreach (var gun in m_activeGuns)
        {
            if (gun.m_type == type)
            {
                if (gun.m_ammo != -1)
                {
                    gun.m_ammo += ammo;
                }
                return;
            }
        }

        DisableGun(m_currentIndex);
        AddGunToList(type);
        m_currentIndex = m_activeGuns.Count - 1;
        EnableGun(m_currentIndex);
    }
Example #14
0
        /// <summary>
        /// Callback function for indicating a weapon switch,
        /// setting the current weapon icon background color
        /// to the "ActiveControl" color.
        /// </summary>
        /// <param name="player">Player number.</param>
        /// <param name="switchToGun">Newly equipped weapon.</param>
        public void CBSwitchWeapon(PlayerNumber player, GunType switchToGun)
        {
            PictureBox oldPBx = null;
            PictureBox newPBx = null;

            // set old and new PictureBox locals
            switch (player)
            {
            case PlayerNumber.One:
                switch (switchToGun)
                {
                case GunType.MachineGun:
                    oldPBx = _pbxRocket1;
                    newPBx = _pbxMG1;
                    break;

                case GunType.Rocket:
                    oldPBx = _pbxMG1;
                    newPBx = _pbxRocket1;
                    break;
                }
                break;

            case PlayerNumber.Two:
                switch (switchToGun)
                {
                case GunType.MachineGun:
                    oldPBx = _pbxRocket2;
                    newPBx = _pbxMG2;
                    break;

                case GunType.Rocket:
                    oldPBx = _pbxMG2;
                    newPBx = _pbxRocket2;
                    break;
                }
                break;
            }

            // reset oldPBx color, and set newPBx color
            oldPBx.BackColor = SystemColors.Control;
            newPBx.BackColor = SystemColors.ActiveCaption;
        }
Example #15
0
    public void ChangeWeapon(GunType newGunType)
    {
        //When you are changing to a pistol

        /*if (newGunType == GunType.Pistol) {
         *      magSize = 6;
         *      reloadSpeed = 2f;
         *      fireRate = 0.0f;
         * }
         *
         * //When you are changing to a shotgun
         * if (newGunType == GunType.Shotgun) {
         * magSize = 2;
         *      reloadSpeed = 5f;
         *      fireRate = 0.5f;
         * }*/

        gunType = newGunType;
    }
Example #16
0
    /// <summary>
    /// 火箭筒发射
    /// </summary>
    private void UseRocketGun(bool use)
    {
        RocketGunNumber = use ? 0 : 1;

        //火箭筒消失
        AllGunCDic[GunType.RocketGun].IfGunCanUse(false);
        AllGunCDic[GunType.RocketGun].SpriteRendererEnabled = false;
        AllGunDic[GunType.RocketGun].GetComponent <BoxCollider2D>().enabled = false;
        //切换为原来的左手武器状态
        m_CurrentLeftGunType = LeftGunType[m_CurrentLeftGunIndex];
        //原来武器消失可用
        AllGunCDic[m_CurrentLeftGunType].IfGunCanUse(true);
        AllGunCDic[m_CurrentLeftGunType].SpriteRendererEnabled = true;
        AllGunDic[m_CurrentLeftGunType].GetComponent <BoxCollider2D>().enabled = true;
        //关闭火箭状态
        m_RocketGunState = false;
        //开启特殊武器功能
        SpecialGunState = true;
    }
Example #17
0
    public GunInfo getGunData(GunType type)
    {
        switch (type)
        {
        case GunType.MachineGun:
            return(MachineGun);

        case GunType.Pistol:
            return(Pistol);

        case GunType.Shotgun:
            return(ShotGun);

        case GunType.SniperRifle:
            return(SniperRifle);
        }

        return(new GunInfo());
    }
Example #18
0
    /// <summary>
    /// 换枪
    /// </summary>
    /// <param name="gt"></param>
    /// <returns></returns>
    public bool ChangeGun(GunType gt)
    {
        Gun g = Instantiate(Prefab_Guns[(int)gt]) as Gun;

        g.GunType_ = gt;

        g.transform.parent        = GunInst.transform.parent;
        g.transform.localPosition = GunInst.transform.localPosition;
        g.transform.localRotation = GunInst.transform.localRotation;

        //方位
        g.TsGun.transform.localPosition = GunInst.TsGun.transform.localPosition;
        g.TsGun.transform.localRotation = GunInst.TsGun.transform.localRotation;


        GunInst.CopyDataTo(g);
        Destroy(GunInst.gameObject);
        GunInst = g;

        //额外的操作
        //在快速切分的话就继续切
//         if (g.FastChangingCoin)
//         {
//             g.StartChangeNeedCoin();
//         }

        //效果
        StartCoroutine(_Coro_Effect_ChangeGun(g));

        //音效
        if (g.Snd_Equip != null)
        {
            GameMain.Singleton.SoundMgr.PlayOneShot(g.Snd_Equip);
        }

        if (GameMain.EvtPlayerGunChanged != null)
        {
            GameMain.EvtPlayerGunChanged(this, g);
        }

        return(true);
    }
Example #19
0
        /// <summary>
        /// Processes new damage to invoking player.
        /// </summary>
        /// <param name="gunfire">Type of weapon that inflicted damage.</param>
        /// <param name="shooter">The player who shot the weapon.</param>
        /// <returns></returns>
        public void TakeDamage(GunType gunfire, PlayerData shooter)
        {
            // player takes damage according to guntype
            if (HasShield)
            {
                HasShield = false;
            }
            else
            {
                switch (gunfire)
                {
                case GunType.MachineGun:
                    HP -= shooter.MachineGunDmg;
                    break;

                case GunType.Rocket:
                    HP -= shooter.RocketDmg;
                    break;
                }
            }

            // if HP is below 0, lose a life
            if (HP <= 0)
            {
                Lives--;

                // reset HP
                HP = HPMax;

                // the shooter gets a point
                shooter.Score++;

                // trigger respawn flag
                IsAlive = false;
            }

            // if shooter reaches 3 points, trigger victory condition
            if (shooter.Score >= ScoreToWin)
            {
                PlayerVictory = true;
            }
        }
    void DrawGlobalSettings()
    {
        EditorGUILayout.BeginVertical("box");
        GUILayout.BeginHorizontal();
        GUILayout.Label("Weapon Info", EditorStyles.toolbarButton);
        if (playerSettings != null)
        {
            GUILayout.Space(2);
            if (GUILayout.Button("GameData", EditorStyles.toolbarButton, GUILayout.Width(70)))
            {
                Selection.activeObject = bl_GameData.Instance;
                EditorGUIUtility.PingObject(bl_GameData.Instance);
            }
            GUILayout.Space(2);
            if (GUILayout.Button("Export", EditorStyles.toolbarButton, GUILayout.Width(50)))
            {
                EditorWindow.GetWindow <bl_ImportExportWeapon>("Export", true).PrepareToExport(script, playerSettings.GetComponent <bl_PlayerSync>());
            }
        }
        GUILayout.EndHorizontal();

        EditorGUILayout.Space();
        script.GunID     = EditorGUILayout.Popup("Gun ID ", script.GunID, GameData.AllWeaponStringList(), EditorStyles.toolbarDropDown);
        script.Info.Type = bl_GameData.Instance.GetWeapon(script.GunID).Type;
        GunType t = script.Info.Type;

        if (t == GunType.Machinegun || t == GunType.Pistol || t == GunType.Burst)
        {
            EditorGUILayout.BeginHorizontal("box");
            int w = ((int)EditorGUIUtility.currentViewWidth / 3) - 25;
            GUI.enabled      = t != GunType.Machinegun;
            script.CanAuto   = EditorGUILayout.ToggleLeft("Auto", script.CanAuto, GUILayout.Width(w));
            GUI.enabled      = t != GunType.Burst;
            script.CanSemi   = EditorGUILayout.ToggleLeft("Semi", script.CanSemi, GUILayout.Width(w));
            GUI.enabled      = t != GunType.Pistol;
            script.CanSingle = EditorGUILayout.ToggleLeft("Single", script.CanSingle, GUILayout.Width(w));
            GUI.enabled      = true;
            EditorGUILayout.EndHorizontal();
        }
        script.CrossHairScale = EditorGUILayout.Slider("CrossHair Scale: ", script.CrossHairScale, 1, 30);
        EditorGUILayout.EndVertical();
    }
Example #21
0
        public override GameState Operate(GameState currentState)
        {
            IEnumerable <PathGraphVertex> path = PathGraph.FindShortestPath(currentState.Position, box.Position, false);
            float     length   = PathGraph.GetLengthOfPath(path);
            GameState newState = currentState.Copy();
            float     duration = length / Human.RunSpeed;

            newState.AddTime(TimeSpan.FromSeconds(duration));
            if (box is ToolBox)
            {
                GunType gunType = Game.BoxDefaultGuns[Game.Random.Next(Game.BoxDefaultGuns.Count)];
                newState.Damage += gunType.Damage * gunType.DefaultBulletCount;
            }
            else
            {
                newState.Health = 100;
            }
            newState.Position = box.Position;
            return(newState);
        }
Example #22
0
    public void UpdateAlternateFireIcon(GunType gun)
    {
        string text = "Current alternate fire: ";

        switch (gun)
        {
        case GunType.FlameThrower:
            text += "Frost";
            break;

        case GunType.MachineGun:
            text += "Grenade Launcher";
            break;

        default:
            text = "No alternate Fire";
            break;
        }
        AlternateFire.GetComponent <Text>().text = text;
    }
Example #23
0
    /// <summary>
    /// 銃の種類を変更する
    /// </summary>
    void WeaponChenge()
    {
        if (Input.GetAxis("Mouse ScrollWheel") > 0)
        {
            m_iGun++;
            if (m_iGun > GunType.RocketLauncher)
            {
                m_iGun = GunType.HandGun;
            }
        }

        if (Input.GetAxis("Mouse ScrollWheel") < 0)
        {
            m_iGun--;
            if (m_iGun < GunType.HandGun)
            {
                m_iGun = GunType.RocketLauncher;
            }
        }
    }
Example #24
0
 public void AddGun(GunType type)
 {
     if (!_guns.ContainsKey(type))
     {
         if (type == GunType.BasicGun)
         {
             _guns[type] = new BasicGun();
         }
         else if (type == GunType.ShotGun)
         {
             _guns[type] = new ShotGun();
         }
         else
         {
             _guns[type] = new Rifle();
         }
     }
     _guns[type].IncreaseBullets();
     _guns[type].PlayerGun = this;
 }
Example #25
0
 public virtual void injure(int hp, GunType gun, Collider collider)
 {
     if (isDead)
     {
         return;
     }
     if (collider == headCollider)
     {
         life -= headShotMultiplayer * hp;
         lastShotWasHeadShot = true;
     }
     else
     {
         lastShotWasHeadShot = false;
         life -= hp;
     }
     lastGunToShoot = gun;
     if (life > 0)
     {
         GetComponent <Animator>().SetTrigger("gotHurt");
     }
     else
     {
         this.isDead = true;
         if (lastGunToShoot == GunType.Bazooka)
         {
             GetComponent <Animator>().SetBool("explosionKilled", true);
             scoreController.addScore("XPlosion!!!", 500);
         }
         else if (lastShotWasHeadShot)
         {
             GetComponent <Animator>().SetBool("headshotKilled", true);
             scoreController.addScore("Headshot!", 500);
         }
         else
         {
             GetComponent <Animator>().SetBool("normalKilled", true);
         }
         scoreController.addScore("Kill", 250);
     }
 }
    public void ChangeGun(int gun)
    {
        switch (gun)
        {
        case 1:
            gunType              = GunEquiped.Shotgun;
            currentGun           = gameObject.AddComponent <Shotgun>();
            magazine.CurrentAmmo = bulletCount[0];
            break;

        case 2:
            gunType              = GunEquiped.M4;
            currentGun           = gameObject.AddComponent <M4>();
            magazine.CurrentAmmo = bulletCount[1];
            break;

        case 3:
            gunType              = GunEquiped.Ak47;
            currentGun           = gameObject.AddComponent <Ak47>();
            magazine.CurrentAmmo = bulletCount[2];
            break;

        case 4:
            gunType              = GunEquiped.M9;
            currentGun           = gameObject.AddComponent <M9>();
            magazine.CurrentAmmo = bulletCount[3];
            break;

        default:
            break;
        }

        currentGun.GetGunTip       = gunTip;
        currentGun.GetBackspinDrag = backspinDrag;
        delayToShoot = currentGun.GetDelayToShoot;

        if (UpdateTypeOfGun.instance)
        {
            UpdateTypeOfGun.instance.SetText(gunType.ToString());
        }
    }
Example #27
0
 void CreateGuns()
 {
     gun1  = new GunType("The PeaShooter", "Basic Gun", 1, BasicBullet, 20, 0.08f, false, 0);
     gun2  = new GunType("The Better Peashooter", "Better Basic Gun", 1, BasicBullet, 20, 0.04f, false, 0);
     gun3  = new GunType("Wide Load", "A Wide Spreaded Gun", 2, BasicBullet, 20, 0.08f, false, 0);
     gun4  = new GunType("The Wiggler", "Rapid Firing Beam", 3, BasicBullet, 20, 0.08f, false, 0);
     gun5  = new GunType("Spread Em", "3 Streams of Bullets", 4, BasicBullet, 20, 0.08f, false, 0);
     gun6  = new GunType("Spread Em Hard", "CORRUPTED - 5 Streams of Bullets", 5, BasicBullet, 20, 0.04f, true, 30);
     gun7  = new GunType("Bomboclaat", "Grenade Launcher", 6, Grenade, 6, 3f, true, 10);
     gun8  = new GunType("Ass Grabber", "Homing Missile", 1, HomingMissile, 25, 2f, true, 20);
     gun9  = new GunType("The Puncher", "CORRUPTED - Short Range Cluster Shot", 7, BasicBullet, 20, 0.04f, true, 0);
     gun10 = new GunType("Flaming PeaShooter", "Fire Effect - Basic Gun", 1, FlamingBullet, 20, 0.08f, false, 0);
     gun11 = new GunType("Frozen PeaShooter", "Ice Effect - Basic Gun", 1, IceBullet, 20, 0.08f, false, 0);
     gun12 = new GunType("Shocking PeaShooter", "Shock Effect - Basic Gun", 1, ShockBullet, 20, 0.08f, false, 0);
     gun13 = new GunType("Fire Punch", "CORRUPTED - Fire Effect - Short Range Cluster Shot", 7, FlamingBullet, 20, 0.04f, true, 0);
     gun14 = new GunType("Shock Whipper", "CORRUPTED - Shock Effect - Rapid Firing Beam", 3, ShockBullet, 20, 0.08f, false, 0);
     gun15 = new GunType("Ice Wave", "Ice Effect - A Wide Spreaded Gun", 2, IceBullet, 20, 0.08f, false, 0);
     gun16 = new GunType("Flaming Spread", "CORRUPTED - Fire Effect - 3 Streams of Bullets", 4, FlamingBullet, 20, 0.08f, true, 0);
     gun17 = new GunType("Lightning Bolt", "CORRUPTED - Shock Effect - Better Basic Gun", 1, ShockBullet, 20, 0.04f, true, 0);
     gun18 = new GunType("Chilly Blow", "CORRUPTED - Ice Effect - Short Range Cluster Shot", 7, IceBullet, 20, 0.04f, true, 0);
 }
Example #28
0
    void TypeSwitch(Projectile _b, GunType _type)
    {
        // type = _type;
        switch (_type)
        {
        case GunType.HANDGUN:
            _b.SetProjectile(BulletType.HANDGUN, 10);
            //  cooldown = 0.5f;
            break;

        case GunType.MACHINEGUN:
            _b.SetProjectile(BulletType.MACHINEGUN, 10, 700);
            //cooldown = 0.3f;
            break;

        case GunType.SHOTGUN:
            _b.SetProjectile(BulletType.SHOTGUN, 20, 400);
            //cooldown = 0.8f;
            break;
        }
    }
Example #29
0
    private void CreatGun(GunType gunType, string path)
    {
        animator.runtimeAnimatorController = Game.Instance.StaticData.Controllers[(int)gunType];
        if (leftGunBone.childCount > 0)
        {
            Destroy(leftGunBone.GetChild(0).gameObject);
        }
        if (rightGunBone.childCount > 0)
        {
            Destroy(rightGunBone.GetChild(0).gameObject);
        }
        switch (gunType)
        {
        case GunType.FreeHand:

            break;

        case GunType.OnePistol:
            GameObject rightOne = Resources.Load <GameObject>(path);

            SetGun(rightOne, true);

            break;

        case GunType.TwoPistol:
            GameObject rightTwo = Resources.Load <GameObject>(path);
            SetGun(rightTwo, true);
            GameObject leftTwo = Resources.Load <GameObject>(path);
            SetGun(leftTwo, false);
            break;

        case GunType.Rifle:
            GameObject rifle = Resources.Load <GameObject>(path);
            SetGun(rifle, true);
            break;

        default:
            break;
        }
    }
Example #30
0
    private void OnPlayerPickItem(object data)
    {
        GunType unknowGunType = (GunType)data;
        int     gunType       = (int)unknowGunType;

        for (int index = 0; index < itemsList.Count; index++)
        {
            if (itemsList[index].GunType.ToString() == "Knife")
            {
                he.currentGun     = GameManager.instance.allWeaponsPossible[gunType];
                itemsList[index]  = GameManager.instance.allWeaponsPossible[gunType];
                indexOfCurrentGun = index;

                EventManager.Instance.UpdateEvent("HeroController_AddItem",
                                                  new OnItemListInfo {
                    indexOfCurrentGun = indexOfCurrentGun,
                    itemsList         = itemsList
                });
                break;
            }
        }
    }
    public virtual bool AddNewGun(GameObject gun)
    {
        if (gun.GetComponent <iGun>().IsCharSupported(charStats.GetStatsType()))
        {
            int        ikey   = 0;
            GameObject oldGun = HasGun(gun.GetComponent <iGun>().GetGunType(), out ikey);
            GunType    key    = GunType.MachineGun;
            if (oldGun != null)
            {
                oldGun             = RemoveOldGun(oldGun, out key);
                rifleObjects[ikey] = gun;
            }
            else
            {
                rifleObjects.Add(gun);
            }
            if (oldGun == currentRifleObject)
            {
                changeRifle(currentRifleType);
                rifleObjects[currentRifleType] = gun;
                //    rifleObjects.Insert(currentRifleType, gun);
            }

            //}else if(currentRifleType > 0)
            //    rifleObjects.Insert(currentRifleType - 1, gun);
            //else rifleObjects.Add(gun);
            Destroy(oldGun);
            return(true);
        }
        else
        {
            if (Tools.IsDebugging())
            {
                Debug.LogError("Char type is not supported by the gun " + gun.GetComponent <iGun>().GetGunType());
            }
            ShowEvent(master.GetGameText().GetPhraseText(PhraseType.GunNotSupported));
        }
        return(false);
    }
Example #32
0
    /// <summary>
    /// 变换为火箭筒
    /// </summary>
    private void ChangeToRocketGun()
    {
        if (RocketGunNumber == 0)
        {
            return;
        }

        //当前武器消失不可用
        AllGunCDic[m_CurrentLeftGunType].IfGunCanUse(false);
        AllGunCDic[m_CurrentLeftGunType].SpriteRendererEnabled = false;
        AllGunDic[m_CurrentLeftGunType].GetComponent <BoxCollider2D>().enabled = false;
        //火箭筒显示
        AllGunCDic[GunType.RocketGun].IfGunCanUse(true);
        AllGunCDic[GunType.RocketGun].SpriteRendererEnabled = true;
        AllGunDic[GunType.RocketGun].GetComponent <BoxCollider2D>().enabled = true;
        //更新当前左手武器类型为火箭筒
        m_CurrentLeftGunType = GunType.RocketGun;
        //开启火箭筒状态
        m_RocketGunState = true;
        //特殊武器无法使用
        SpecialGunState = false;
    }
Example #33
0
    public void SwitchGun(GunType newGun)
    {
        GameObject gun, model;

        switch (newGun)
        {
        case GunType.GRENADE_LAUNCHER:
            gun   = grenadeLauncherGun;
            model = grenadeLauncherModel;
            break;

        default:
            gun   = revolverGun;
            model = revolverModel;
            break;
        }

        //Destroy(transform.GetChild(0));
        Instantiate(gun, transform);
        Instantiate(model, modelTransform);
        input.gun = gun.GetComponent <Gun>();
    }
Example #34
0
    public override int Request(GunType gunType, int amountRequested)
    {
        int returnAmount = 0;

        if (bullets[gunType] >= amountRequested)
        {
            bullets[gunType] -= amountRequested;
            returnAmount      = amountRequested;
        }
        else
        {
            returnAmount     = bullets[gunType];
            bullets[gunType] = 0;
        }

        if (CB_AmmoChanged != null)
        {
            CB_AmmoChanged();
        }

        return(returnAmount);
    }
Example #35
0
        /// <summary>
        /// Default instance constructor for new gunfire.
        /// Sets initial position and gun type.
        /// </summary>
        /// <param name="position">
        /// Initial location of the gun blast.
        /// </param>
        /// <param name="rotation">
        /// Angle of gun fire.
        /// </param>
        /// <param name="gunType">
        /// Type of gun fired.
        /// </param>
        /// <param name="color">
        /// Color of gunfire shape.
        /// </param>
        /// <param name="player">
        /// Player index.
        /// </param>
        public Gunfire(PointF position, float rotation, GunType gunType, Color color, PlayerNumber player)
            : base(position, color, player)
        {
            // set angle of gun fire
            Rotation = rotation;

            // set gunfire initial position
            Position = new PointF(position.X, position.Y);

            // gunfire speed magnitude i.e. the hypotenuse
            float speed = 0;

            // initialize gunfire model
            _model = new GraphicsPath();

            // set gunfire properties according to gun type
            Gun = gunType;
            switch (Gun)
            {
            case GunType.MachineGun:
                // draw a little ellipse for the mg bullet
                _model.AddEllipse(_rfMachineGunModel);
                speed = _iMachineGunSpeed;
                break;

            case GunType.Rocket:
                // draw a little rectangle for the rocket
                _model.AddRectangle(_rfRocketModel);
                speed = _iRocketSpeed;
                break;
            }

            // set angle in radians
            double angle = Math.PI / 180 * rotation;

            // use trigonometry to set the x and y speeds
            XSpeed = speed * (float)Math.Cos(angle);
            YSpeed = speed * (float)Math.Sin(angle);
        }
Example #36
0
    void changeWeaponType(GunType weaponType)
    {
        float targetPosition = 0.0f;

        switch (weaponType)
        {
        case GunType.Pistol:
            targetPosition = 164.0f;
            break;

        case GunType.MachineGun:
            targetPosition = 122.0f;
            break;

        case GunType.Bazooka:
            targetPosition = 80.0f;
            break;
        }
        Vector3 oldPosition = selectWeaponsPanel.rectTransform.position;

        selectWeaponsPanel.rectTransform.position = new Vector3(oldPosition.x, targetPosition, oldPosition.z);
    }
    public void Dock()
    {
        List <GunType> gunTypes = new List <GunType>();

        foreach (GunType gt in System.Enum.GetValues(typeof(GunType)))
        {
            if (gt == player.GetComponent <Player>().gunType)
            {
                continue;
            }

            gunTypes.Add(gt);
        }
        planetGunType = gunTypes[Random.Range(0, gunTypes.Count)];

        player.GetComponent <Player>().Dock();
        player.GetComponent <Player>().enabled = false;
        UIManager.instance.SetDockedMenuActive(true, planetGunType);
        mainCam.SetActive(false);
        garageCam.SetActive(true);
        Time.timeScale = 0;
    }
Example #38
0
 public async void AddGunType(object o, EventArgs e)
 {
     _gunType         = new GunType();
     _gunTypeDatabase = new GunTypeDatabase();
     try
     {
         if (!string.IsNullOrEmpty(gunType.Text))
         {
             _gunType.GunTypeName = gunType.Text;
             _gunTypeDatabase.AddGunType(_gunType);
             Navigation.RemovePage(this);
         }
         else
         {
             await DisplayAlert("Field Error", "Type is required", "OK");
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(@"                GunStock.GunTypeEntryPage.AddGunType ERROR {0}", ex.Message);
     }
 }
Example #39
0
    /// <summary>
    /// 切换主武器的当前手里的枪
    /// </summary>
    /// <param name="TargetGunIndex">切换的目标的枪索引</param>
    private bool ChangeLeftGun(int TargetGunIndex)
    {
        //切枪系统无法用
        if (!ChangeLeftGunState)
        {
            return(true);
        }
        //当前状态是否火箭筒状态
        if (m_RocketGunState)
        {
            UseRocketGun(false);
        }

        if (TargetGunIndex < 0)
        {
            TargetGunIndex += LeftGunType.Length;
        }
        TargetGunIndex = TargetGunIndex % LeftGunType.Length;

        //当前槽位为空,无法切枪
        if (LeftGunType[TargetGunIndex] == GunType.Null)
        {
            return(false);
        }

        //修改武器属性--
        ChangeLeftGunData(m_CurrentLeftGunIndex, TargetGunIndex);
        //--------------
        //当前枪索引更新
        m_CurrentLeftGunIndex = TargetGunIndex;
        //当前抢类型更新
        m_CurrentLeftGunType = LeftGunType[m_CurrentLeftGunIndex];

        //更新CDSlider
        Target.Instance.InitZeroCDSlider();

        return(true);
    }
Example #40
0
        /// <summary>
        /// Constructor
        /// </summary>
        public BasicGun(IGunner owner, int damage, float range, int fireRate, float bulletSpeed, FireMode fireMode, 
            float recoilPerShot, float maxRecoil, int clipSize, int reserveSize, int reloadTime, World world, string weaponName, GunType gunType)
        {
            this.owner = owner;
            this.damage = damage;
            this.range = range;
            this.fireRate = fireRate;
            this.bulletSpeed = bulletSpeed;
            this.fireMode = fireMode;
            this.recoilPerShot = recoilPerShot;
            this.maxRecoil = maxRecoil;
            this.clipSize = clipSize;
            this.reserveSize = reserveSize;
            this.reloadTime = reloadTime;
            this.world = world;
            this.weaponName = weaponName;
            this.gunType = gunType;
            clipAmmo = clipSize;
            reserveAmmo = reserveSize;

            currentRecoil = 0;
            random = new Random();
        }
Example #41
0
    private uint mScoreChangeLowest = 0; //��ͷ���ֵ

    #endregion Fields

    #region Methods

    /// <summary>
    /// ��ǹ
    /// </summary>
    /// <param name="gt"></param>
    /// <returns></returns>
    public bool ChangeGun(GunType gt)
    {
        Gun g = Instantiate(Prefab_Guns[(int)gt]) as Gun;
        g.GunType_ = gt;

        g.transform.parent = GunInst.transform.parent;
        g.transform.localPosition = GunInst.transform.localPosition;
        g.transform.localRotation = GunInst.transform.localRotation;

        //��λ
        g.TsGun.transform.localPosition = GunInst.TsGun.transform.localPosition;
        g.TsGun.transform.localRotation = GunInst.TsGun.transform.localRotation;

        GunInst.CopyDataTo(g);
        Destroy(GunInst.gameObject);
        GunInst = g;

        //����IJ���
        //�ڿ����зֵĻ��ͼ�����
        //         if (g.FastChangingCoin)
        //         {
        //             g.StartChangeNeedCoin();
        //         }

        //��
        StartCoroutine(_Coro_Effect_ChangeGun(g));

        //��Ч
        if (g.Snd_Equip != null)
            GameMain.Singleton.SoundMgr.PlayOneShot(g.Snd_Equip);

        if (GameMain.EvtPlayerGunChanged != null)
            GameMain.EvtPlayerGunChanged(this, g);

        return true;
    }
 /// <summary>
 /// Alternates between random gun and stream shot
 /// </summary>
 public void PickNextGunType()
 {
     //If he fired stream last time, fire random this time.
     if (gunType == GunType.Stream)
     {
         switch (Random.Range(0, 3))
         {
             case 0:
                 gunType = GunType.Shotgun;
                 break;
             case 1:
                 gunType = GunType.Laser;
                 break;
             case 2:
                 gunType = GunType.Homing;
                 break;
         }
     }
     else
     {
         gunType = GunType.Stream;
     }
 }
Example #43
0
 /// <summary>
 /// Creates a new gun.
 /// </summary>
 /// <param name="type">The type of this gun</param>
 /// <param name="bullets">The number of available ammo</param>
 /// <param name="game">The game</param>
 public Gun(GunType type, int bullets, ActionGame game)
     : this(type, bullets, null, game)
 {
 }
Example #44
0
 /// <summary>
 /// Creates a new gun
 /// </summary>
 /// <param name="type">The type of this gun</param>
 /// <param name="bullets">The number of available ammo</param>
 /// <param name="handler">The holder of this gun</param>
 /// <param name="game">The game</param>
 public Gun(GunType type, int bullets, Human handler, ActionGame game)
     : base(type.Icon, handler, game)
 {
     this.type = type;
     this.bullets = bullets;
 }
 /// <summary>
 /// Checks if we are only firing one weapon type. Good for debug and possible boss setups
 /// </summary>
 public void FireOnlyCheck()
 {
     if (fireOnly != 0)
     {
         if (fireOnly == 1)
         {
             gunType = GunType.Stream;
         }
         if (fireOnly == 2)
         {
             gunType = GunType.Shotgun;
         }
         if (fireOnly == 3)
         {
             gunType = GunType.Homing;
         }
         if (fireOnly == 4)
         {
             gunType = GunType.Laser;
         }
     }
 }
 public Gun(GunType _gunType, GunSprite _parent)
 {
     bullets = new List<Bullet> ();
     parent = _parent;
     gunType = _gunType;
     width = Tile.WIDTH;
     height = Tile.HEIGHT;
     ChangeGun ();
 }
Example #47
0
    // Use this for initialization
    void Start()
    {
        gunType = GameManager.gameManager.CurrentWeaponChoice;
        switch (gunType) {
            case GunType.CANNON:
                ammunitionPrefab = (GameObject)Resources.Load("Bullet");
                weaponType = WeaponType.BULLET;
                break;

            case GunType.SEEKERMISSILELAUNCHER:
                ammunitionPrefab = (GameObject)Resources.Load("SeekerMissile");
                weaponType = WeaponType.SEEKER;
                break;

            default:
                break;
        }

        GameManager.gameManager.ClientController.Register(this);

        rapidTex = Resources.Load("Textures/Rapidfire") as Texture2D;
    }
Example #48
0
    // Use this for initialization
    void Start()
    {
        InitiliseAmmo();

        CurrentGunMode = GunMode.Standard;
        CurrentGunType = GunType.SingleShot;
    }
Example #49
0
 public void GunChange(GunType _gunType)
 {
     gunType = _gunType;
     GunController.Instance.SetGun(gunType);
 }
Example #50
0
 public static void NexGun()
 {
     CurrentGun = Guns[(Guns.IndexOf(CurrentGun) + 1) == Guns.Count ? 0 : (Guns.IndexOf(CurrentGun) + 1)];
 }
Example #51
0
 void AddGunToList(GunType type)
 {
     foreach(var gun in m_allGuns) {
         if(gun.m_type == type) {
             m_activeGuns.Add (gun);
             return;
         }
     }
 }
Example #52
0
 /// <summary>
 /// Loads gun types setting from attached xml file.
 /// </summary>
 void LoadGunTypes()
 {
     try
     {
         string fileName = settings.GunSetFilename;
         XmlDocument doc = new XmlDocument();
         string fullPath = String.Format(@"Content\Config\{0}", fileName);
         if (!fullPath.EndsWith(".xml", StringComparison.CurrentCultureIgnoreCase))
             fullPath += ".xml";
         doc.Load(fullPath);
         XmlNodeList gunNodes = doc.SelectNodes("/guns/*");
         gunTypes = new Dictionary<string, GunType>(gunNodes.Count);
         guardDefaultGuns.Clear();
         boxDefaultGuns.Clear();
         humanDefaultGuns.Clear();
         playerDefaultGuns.Clear();
         foreach (XmlNode gunNode in gunNodes)
         {
             string texture = gunNode.SelectSingleNode("icon").InnerText;
             Texture2D icon = Content.Load<Texture2D>("Textures/ToolIcons/" + texture);
             string sound = gunNode.SelectSingleNode("sound").InnerText;
             SoundEffect shotSound = Content.Load<SoundEffect>("Sounds/ToolActions/" + sound);
             bool infinity = bool.Parse(gunNode.SelectSingleNode("infinity").InnerText);
             TimeSpan shotTimeout = new TimeSpan(0, 0, 0, 0, int.Parse(gunNode.SelectSingleNode("shotTimeout").InnerText));
             GunType gunType = new GunType(
                 int.Parse(gunNode.SelectSingleNode("damage").InnerText),
                 float.Parse(gunNode.SelectSingleNode("range").InnerText, CultureInfo.InvariantCulture.NumberFormat),
                 infinity,
                 shotTimeout,
                 (infinity ? 0 : int.Parse(gunNode.SelectSingleNode("defaultBulletCount").InnerText)),
                 icon,
                 shotSound
                 );
             gunTypes.Add(gunNode.Attributes["name"].Value, gunType);
             if (gunNode.Attributes["available"].Value == "human")
                 humanDefaultGuns.Add(gunType);
             if (gunNode.Attributes["available"].Value == "guard" || gunNode.Attributes["available"].Value == "player" || gunNode.Attributes["available"].Value == "box")
             {
                 boxDefaultGuns.Add(gunType);
                 if (gunNode.Attributes["available"].Value == "player" || gunNode.Attributes["available"].Value == "guard")
                 {
                     playerDefaultGuns.Add(gunType);
                     if (gunNode.Attributes["available"].Value == "guard")
                     {
                         guardDefaultGuns.Add(gunType);
                     }
                 }
             }
         }
     }
     catch
     {
         Exit();
     }
 }
Example #53
0
 public void ChangeGun(Entity e, GunType gun)
 {
     if (e.GetComponent<Gun>() != null)
     {
         CurrentGun.Ammunition = e.GetComponent<Gun>().Ammunition;
         e.RemoveComponent<Gun>(e.GetComponent<Gun>());
     }
     _CurrentGunType = gun;
     e.AddComponent<Gun>(CurrentGun);
 }
Example #54
0
 void Update()
 {
     if (!GunController.Instance.CheckGun())
     {
         //Sung da het dan, hoac khong co cay sung nay
         gunType = GunType.SHOOT_GUN;
         GunController.Instance.SetGun(gunType);
     }
     /*
     if (isShoot)
     {
         timeAttackCurrent += Time.deltaTime;
         if (timeAttackCurrent >= timeDelayAttack)
         {
             isShoot = false;
             ChangeState(CowboyState.IDLE_STATE);
             timeAttackCurrent = 0.0f;
         }
     }
      * */
 }
Example #55
0
 public void AddBulletsToGun(GunType gunType, int numberOfBullets)
 {
     foreach (Gun g in this.arms)
     {
         if (g.GunType == gunType)
         {
             g.NumberOfBullets += numberOfBullets;
             break;
         }
     }
 }
Example #56
0
 public AmmoPack()
     : base()
 {
     this.quantity = 0;
     this.gunType = GunType.None;
 }
Example #57
0
 void Update()
 {
     #if UNITY_EDITOR
     UpdateInput();
     #endif
     gunType = GetGuntype();
     if (gunType == GunType.MACHINE_GUN)
     {
         if (GameController.Instance.heroCowboy != null)
         {
             if (isDown)
             {
                 if (isRightClick)
                 {
                     GameController.Instance.heroCowboy.Rotation(false);
                     GameController.Instance.heroCowboy.AllowCowboyShoot();
                 }
                 else
                 {
                     GameController.Instance.heroCowboy.Rotation(true);
                     GameController.Instance.heroCowboy.AllowCowboyShoot();
                 }
             }
         }
     }
 }
Example #58
0
 public void SetType(int type)
 {
     gunType = (GunType)type;
 }