Beispiel #1
0
        /// <summary>
        /// Load the player contents like model, weapons, ...
        /// </summary>
        protected override void LoadContent()
        {
            base.LoadContent();

            //Initialize WeaponManager
            if (Weapons == null)
            {
                Weapons = new WeaponManager(game, Model, WeaponHolderType.Enemy);

                // Equip some cool weapons:
                Weapons.AddWeapon(WeaponType.ROCKET_STINGER);
                Weapons.AddWeapon(WeaponType.ULTRA_PHASER);
                Weapons.SetAmmo(AmmoType.ROCKETS, 0);
                Weapons.SetAmmo(AmmoType.LASERCELLS, 9999);

                Weapons.SetPrimaryWeapon(WeaponType.ULTRA_PHASER);
                Weapons.PrimaryWeapon.FirePause = TimeSpan.FromMilliseconds(2000);

                Weapons.SetSecondaryWeapon(WeaponType.ROCKET_STINGER);
                Weapons.SecondaryWeapon.FirePause      = TimeSpan.FromMilliseconds(3000);
                Weapons.SecondaryWeapon.AmmoInMagazine = 3;
            }
            else
            {
                Weapons.WeaponHolder = Model;
            }
        }
Beispiel #2
0
 // Start is called before the first frame update
 void Start()
 {
     PlayerWeaponManager.AddWeapon(WeaponFactory.GetWeapon("Gun 1"));
     PlayerWeaponManager.AddWeapon(WeaponFactory.GetWeapon("Gun 2"));
     PlayerWeaponManager.AddWeapon(WeaponFactory.GetWeapon("Gun 3"));
     PlayerWeaponManager.AddWeapon(WeaponFactory.GetWeapon("Gun 4"));
 }
Beispiel #3
0
        /// <summary>
        /// Load the player contents like model, weapons, ...
        /// </summary>
        protected override void LoadContent()
        {
            base.LoadContent();
            Model.AfterBurnerLength = minBooster;
            //Initialize WeaponManager
            if (Weapons == null)
            {
                Weapons = new WeaponManager(game, Model, WeaponHolderType.Player);

                // Equip standard weapons:
                Weapons.AddWeapon(WeaponType.MINIGUN);
                Weapons.AddWeapon(WeaponType.MINIGUN2);
                Weapons.AddWeapon(WeaponType.ULTRA_PHASER);
                Weapons.AddWeapon(WeaponType.ROCKET_STINGER);
                Weapons.SetPrimaryWeapon(WeaponType.ULTRA_PHASER);
                Weapons.SetSecondaryWeapon(WeaponType.ROCKET_STINGER);
            }
            else
            {
                Weapons.WeaponHolder = Model;
            }

            // Helicopter animation hack
            modelAnimationPart = Model.GetMesh("Rotor");
            if (modelAnimationPart != null)
            {
                meshSoundEfx = game.Sounds.CreateSound("Heli");
                meshSoundEfx.Play();
                modelAnimationPart.PlayRotationAnimation();
            }
            // -------------------------------------
        }
Beispiel #4
0
        protected override void LoadContent()
        {
            base.LoadContent();
            if (Weapons == null)
            {
                //Initialize WeaponManager
                Weapons = new WeaponManager(game, Model, WeaponHolderType.Player);

                // Equip some cool weapons:
                //TODO: remove this later.
                Weapons.AddWeapon(WeaponType.ROCKET_STINGER);
                Weapons.AddWeapon(WeaponType.ULTRA_PHASER);
                Weapons.AddWeapon(WeaponType.MINIGUN);
                Weapons.AddWeapon(WeaponType.MINIGUN2);
                Weapons.AddWeapon(WeaponType.PLASMAGUN);
            }
            else
            {
                Weapons.WeaponHolder = Model;
            }
            // For audio and mesh animation by M.R.
            modelAnimationPart = Model.GetMesh("Rotor");
            if (modelAnimationPart != null)
            {
                meshSoundEfx = game.Sounds.CreateSound("Heli");
                meshSoundEfx.Play();
                modelAnimationPart.PlayRotationAnimation();
            }
            // -------------------------------------
        }
Beispiel #5
0
    /*
     * OnTriggerEnter2D
     * see link: https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter2D.html
     * we get the WeaponManager component from the player
     * we then add the weapon prefab using the WeaponManager's AddWeapon method
     * finally, we destroy this pickup, as it has been picked up!
     */
    private void OnTriggerEnter2D(Collider2D other)
    {
        /*
         * GET THE PLAYERS WeaponManager COMPONENT
         * we get the WeaponManager using GetComponentInChildren, this will search for the WeaponManager
         * component in all of the player GameObject's children GameObjects
         * see link: https://docs.unity3d.com/ScriptReference/Component.GetComponentInChildren.html
         */
        WeaponManager weaponManager = other.gameObject.GetComponentInChildren <WeaponManager>();


        /*
         * if we found a WeaponManager component, we can add the weapon
         */
        if (weaponManager != null) // if we found a WeaponManager component
        {
            /*
             * ADD THE NEW WEAPON TO THE PLAYER'S WeaponManager COMPONENT
             * call the AddWeapon method on the WeaponManager and give it the weapon prefab
             */
            weaponManager.AddWeapon(weaponPrefab);


            /*
             * DESTROY THE WEAPON PICKUP GAMEOBJECT
             * see link: https://docs.unity3d.com/ScriptReference/Object.Destroy.html
             * here we destroy the weapon pickup GameObject so the player can't pick it up again
             */
            Destroy(gameObject);
        }
    }
Beispiel #6
0
        protected override void LoadContent()
        {
            base.LoadContent(); //Wichtig, base muss vorher aufgerufen werden,
            //damit die GameObject-Klasse das Model lädt

            #region Helicopter animation hack
            modelAnimationPart = this.Model.GetMesh("Rotor");
            if (modelAnimationPart != null)
            {
                FxSound        = game.Sounds.CreateSound("Heli");
                FxSound.Loop   = true;
                FxSound.Parent = this;
                modelAnimationPart.PlayRotationAnimation();
            }
            #endregion

            #region Init WeaponManager and add Weapons
            if (weapons == null)
            {
                weapons = new WeaponManager(game, Model, WeaponHolderType.Enemy);


                foreach (string weapon in typeDesc.Weapons)
                {
                    weapons.AddWeapon((WeaponType)Enum.Parse(typeof(WeaponType), weapon, true));
                    //       weapons.SwitchUp(false);
                }

                AI.AddState(new AI2AttackPlayer(weapons, 2));
            }
            #endregion
        }
Beispiel #7
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         wManager.AddWeapon(this);
         Destroy(gameObject);
     }
 }
Beispiel #8
0
    void pickUp()
    {
        audio.PlayOneShot(pickUpSound);
        renderer.enabled = false;
        triggered        = false;

        manager.AddWeapon(prefab, rotation);
        Destroy(gameObject);
    }
Beispiel #9
0
 void pickupObject()
 {
     if (Input.GetButtonDown("Pickup") && toPickup != null)
     {
         AudioManager.instance.Play(pickupSound, gameObject, true, playerID);
         weaponManager.AddWeapon(toPickup);
         HUD.instance.pickupPanel.CloseMessagePanel();
         toPickup = null;
     }
 }
Beispiel #10
0
 public void PickUpGun(Collider col, Gun gun)
 {
     if (col.tag == "Player")
     {
         WeaponManager wm = col.GetComponent <WeaponManager>();
         wm.AddWeapon(gun);
         wm.SwitchWeapon(gun);
         Destroy(gameObject);
     }
 }
Beispiel #11
0
    void Start()
    {
        policeScript  = GetComponent <PoliceScript>();
        weaponManager = GetComponent <WeaponManager>();
        rb2d          = GetComponent <Rigidbody2D>();

        weaponManager.AddWeapon(WeaponFactory.GetWeapon("Gun 1"));
        weaponManager.NextWeapon();
        weapon = weaponManager.CurrentWeapon.GetComponent <IWeapon>();
    }
Beispiel #12
0
        protected override void OnPlayerPickup(PlayerManager player)
        {
            WeaponManager weaponManager = player.GetComponent <WeaponManager>();

            //Don't want to pickup the same weapon
            if (weaponManager.GetWeaponFromId(weapon.weaponId) != null)
            {
                return;
            }

            weaponManager.AddWeapon(weapon);

            base.OnPlayerPickup(player);
        }
Beispiel #13
0
    /**
     * Spawn greandes in the area
     */
    private void SpawnGrenades()
    {
        string funcName = "SpawnGrenades";

        FunctionPeriodic.Create(
            () =>
        {
            if (WeaponManager.WeaponCount <Grenade>() < _GRENADE_MAX_SPAWNS)
            {
                Vector3 grenadeWorldPosition = new Vector3(
                    Random.Range(-_MAX_RADIUS, _MAX_RADIUS),
                    AssetManager.Get_Prefab_Grenade().transform.localScale.y / 2 + AssetManager.GetTerrain().localScale.y,
                    Random.Range(-_MAX_RADIUS, _MAX_RADIUS)
                    );

                Grenade grenade = Instantiate(
                    AssetManager.Get_Prefab_Grenade(),
                    grenadeWorldPosition,
                    Quaternion.identity
                    );

                WeaponManager.AddWeapon(grenade);
            }
        },
            funcName,
            0f,
            0f,
            () =>
        {
            if (WeaponManager.WeaponCount <Grenade>() >= _GRENADE_MAX_SPAWNS)
            {
                Destroy(GameObject.Find(funcName));
            }
        }
            );
    }
Beispiel #14
0
    /**
     * Spawn enforcers in the area
     */
    private void SpawnEnforcers()
    {
        string funcName = "SpawnEnforcers";

        FunctionPeriodic.Create(
            () =>
        {
            if (WeaponManager.WeaponCount <Enforcer>() < _ENFORCER_MAX_SPAWNS)
            {
                Vector3 enforcerWorldPosition = new Vector3(
                    Random.Range(-_MAX_RADIUS, _MAX_RADIUS),
                    AssetManager.Get_Prefab_Enforcer().transform.localScale.y / 2 + AssetManager.GetTerrain().localScale.y,
                    Random.Range(-_MAX_RADIUS, _MAX_RADIUS)
                    );

                Enforcer enforcer = Instantiate(
                    AssetManager.Get_Prefab_Enforcer(),
                    enforcerWorldPosition,
                    Quaternion.identity
                    );

                WeaponManager.AddWeapon(enforcer);
            }
        },
            funcName,
            0f,
            0f,
            () =>
        {
            if (WeaponManager.WeaponCount <Enforcer>() >= _ENFORCER_MAX_SPAWNS)
            {
                Destroy(GameObject.Find(funcName));
            }
        }
            );
    }
Beispiel #15
0
    /**
     * Spawn hunting rifles in the area
     */
    private void SpawnHuntingRifles()
    {
        string funcName = "SpawnHuntingRifles";

        FunctionPeriodic.Create(
            () =>
        {
            if (WeaponManager.WeaponCount <HuntingRifle>() < _HUNTING_RIFLE_MAX_SPAWNS)
            {
                Vector3 huntingRifleWorldPosition = new Vector3(
                    Random.Range(-_MAX_RADIUS, _MAX_RADIUS),
                    AssetManager.Get_Prefab_HuntingRifle().transform.localScale.y / 2 + AssetManager.GetTerrain().localScale.y,
                    Random.Range(-_MAX_RADIUS, _MAX_RADIUS)
                    );

                HuntingRifle huntingRifle = Instantiate(
                    AssetManager.Get_Prefab_HuntingRifle(),
                    huntingRifleWorldPosition,
                    Quaternion.identity
                    );

                WeaponManager.AddWeapon(huntingRifle);
            }
        },
            funcName,
            0f,
            0f,
            () =>
        {
            if (WeaponManager.WeaponCount <HuntingRifle>() >= _HUNTING_RIFLE_MAX_SPAWNS)
            {
                Destroy(GameObject.Find(funcName));
            }
        }
            );
    }
Beispiel #16
0
        /// <param name="desc">The description data (i.e. healthpoints, strength).</param>
        public EnemyAI2(ICanyonShooterGame game, EnemyDescription desc)
            : base(game, "Enemy-AI2")
        {
            this.game = game;

            // Physics Config
            ConnectedToXpa      = true;
            ContactGroup        = ContactGroup.Enemies;
            InfluencedByGravity = false;
            LocalPosition       = desc.RelativeSpawnLocation;
            typeDesc            = game.Content.Load <EnemyTypeDescription>("Content\\Enemies\\" + desc.Type);
            currentHitpoints    = typeDesc.MaxHitpoints;
            SetModel(typeDesc.Model);
            LocalScale = new Vector3(1.5f, 1.5f, 1.5f);
            itemChance = desc.ItemChance;
            itemList   = desc.ItemList;

            if (game.Graphics.ShadowMappingSupported)
            {
                game.World.Sky.Sunlight.ShadowMapLow.Scene.AddDrawable(this);
                game.World.Sky.Sunlight.ShadowMapHigh.Scene.AddDrawable(this);
            }

            #region Init WeaponManager and add Weapons
            if (weapons == null)
            {
                weapons = new WeaponManager(game, Model, WeaponHolderType.Enemy);


                foreach (string weapon in typeDesc.Weapons)
                {
                    weapons.AddWeapon((WeaponType)Enum.Parse(typeof(WeaponType), weapon, true));
                }
            }
            #endregion
        }
Beispiel #17
0
        public override void OnInspectorGUI()
        {
            //Update the serializedProperty - always do this in the beginning of OnInspectorGUI
            serializedObject.Update();

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(m_FPController, new GUIContent("First Person Character"));
            EditorGUILayout.PropertyField(m_CameraTransformReference);
            EditorGUILayout.PropertyField(m_InteractionRadius);
            EditorGUILayout.PropertyField(m_WeaponSwitchMode);
            EditorGUILayout.PropertyField(m_FastChangeWeapons);

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(m_AmmoTag);
            EditorGUILayout.PropertyField(m_AdrenalinePackTag);
            EditorGUILayout.PropertyField(m_ItemPickupSound);
            EditorGUILayout.PropertyField(m_ItemPickupVolume);

            EditorGUILayout.Space();
            EditorGUI.indentLevel = 0;
            EditorGUILayout.LabelField("Equipped Weapons" + " (" + m_EquippedWeaponsList.arraySize + (m_EquippedWeaponsList.arraySize > 1 ? " Slots)" : " Slot)"), EditorStyles.boldLabel);

            using (new EditorGUILayout.VerticalScope(Styling.background))
            {
                if (m_EquippedWeaponsList.arraySize == 0)
                {
                    EditorGUILayout.HelpBox("No weapon slot", MessageType.Info);

                    EditorGUI.BeginChangeCheck();
                    if (GUILayout.Button("Add new slot"))
                    {
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(m_Target, "Undo Inspector");
                            m_Target.AddWeaponSlot();

                            EditorUtility.SetDirty(m_Target);
                            return;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < m_EquippedWeaponsList.arraySize; i++)
                    {
                        ShowEquippedWeapons(i);
                    }
                }
            }

            EditorGUILayout.Space();
            EditorGUI.indentLevel = 0;
            EditorGUILayout.LabelField("Weapon List", EditorStyles.boldLabel);

            using (new EditorGUILayout.VerticalScope(Styling.background))
            {
                if (m_WeaponList.arraySize == 0)
                {
                    EditorGUILayout.HelpBox("No weapon available", MessageType.Info);

                    EditorGUI.BeginChangeCheck();
                    if (GUILayout.Button("Add new weapon"))
                    {
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(m_Target, "Undo Inspector");
                            m_Target.AddWeapon();

                            EditorUtility.SetDirty(m_Target);
                            return;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < m_WeaponList.arraySize; i++)
                    {
                        ShowWeaponList(i);
                    }
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(m_DefaultWeapon);

            EditorGUILayout.Space();
            EditorGUI.indentLevel = 0;
            EditorGUILayout.LabelField("Items", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(m_FragGrenade);
            EditorGUILayout.PropertyField(m_Adrenaline);

            //Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI
            serializedObject.ApplyModifiedProperties();
        }
        void NewMapHandling(object sender, EventArgs e)
        {
            //TODO: Get weapons by map actors
            weaponManager.AddWeapon(new Actors.Weapons.Pistol(actorManager, particleManager, tileMap, camera, content));

            actorManager.Reset();
            List <Vector2> playerLocations = tileMap.GetLocationOfCodeValue("player");

            if (playerLocations.Count > 0)
            {
                foreach (Vector2 playerLocation in playerLocations)
                {
                    player = new Actors.Player(actorManager, tileMap, camera, playerLocation + new Vector2(16, 16), content.Load <Texture2D>(@"Textures/player"), 25.0f, 16, 16, 15, 15);
                    player.WeaponManager = this.weaponManager;
                    actorManager.AddPlayer(player);
                }
            }
            else
            {
                player = new Actors.Player(actorManager, tileMap, camera, new Vector2(16, 16), content.Load <Texture2D>(@"Textures/player"), 25.0f, 16, 16, 15, 15);
                player.WeaponManager = this.weaponManager;
                actorManager.AddPlayer(player);
            }
            this.player = actorManager.GetNextPlayer();

            List <Vector2> mobLocations = tileMap.GetLocationOfCodeValue("mob");

            foreach (Vector2 mobLocation in mobLocations)
            {
                Actors.Mobs.Chaser chaser = new Actors.Mobs.Chaser(actorManager, particleManager, tileMap, camera, mobLocation + new Vector2(16, 16), content, 30, 30, 30, 30);
                chaser.ChaseTarget = this.player;
                actorManager.AddMapObject(chaser);
            }

            Dictionary <Vector2, int> actors = tileMap.GetActorsLocationAndID();

            foreach (KeyValuePair <Vector2, int> actor in actors)
            {
                StaticObject obj;
                if (actor.Value <= gateMapper.LastGateID)
                {
                    obj = new Gate(this.tileMap, this.camera, actor.Key, gateMapper.GetTextureByID(actor.Value), tileMap.SourceTileWidth, tileMap.SourceTileHeight, gateMapper.GetTagByID(actor.Value), gateMapper.IsGateEnabled(actor.Value));
                }
                else if (actor.Value == gateMapper.CoinID)
                {
                    obj = new Coin(this.tileMap, this.camera, actor.Key, gateMapper.GetTextureByID(actor.Value), tileMap.SourceTileWidth, tileMap.SourceTileHeight, gateMapper.GetTagByID(actor.Value));
                }
                else if (actor.Value == gateMapper.HiddenWallID)
                {
                    obj = new HiddenWall(this.tileMap, this.camera, actor.Key, gateMapper.GetTextureByID(actor.Value), tileMap.SourceTileWidth, tileMap.SourceTileHeight, gateMapper.GetTagByID(actor.Value));
                }
                else if (actor.Value == gateMapper.CloneBoxID)
                {
                    obj = new CloneBox(this.actorManager, this.particleManager, this.tileMap, this.camera, actor.Key, gateMapper.GetTextureByID(actor.Value), content, tileMap.SourceTileWidth, tileMap.SourceTileHeight, gateMapper.GetTagByID(actor.Value));
                }
                else
                {
                    obj = new Button(this.tileMap, this.camera, actor.Key, gateMapper.GetTextureByID(actor.Value), tileMap.SourceTileWidth, tileMap.SourceTileHeight, gateMapper.GetTagByID(actor.Value));
                }
                obj.CollisionRectangle   = gateMapper.GetCollisionRectangleByID(actor.Value, actor.Key);
                obj.InteractionRectangle = gateMapper.GetInteractionRectangleByID(actor.Value, actor.Key);

                actorManager.AddStaticObject(obj);
            }
        }