Example #1
0
        public void Shoot()
        {
            GameObject weapon = GetComponent <Operator.OperatorState>().Weapon;

            Weapon.Weapon weaponScript = weapon.GetComponent <Weapon.Weapon>();
            if (Target != null)
            {
                Vector3 vectorToTarget = Target.transform.position - transform.position;
                Vector3 rotation       = transform.up;
                float   angle          = Vector3.Angle(rotation, vectorToTarget);
                // CALCULATE THE NEEDED ANGLE GIVEN THE DISTANCE
                if (angle < 1f)
                {
                    weaponScript.FireAt(Target);
                }
                else
                {
                    GetComponent <Animator>().SetBool("Firing", false);
                }
            }
            else
            {
                GetComponent <Animator>().SetBool("Firing", false);
            }
        }
Example #2
0
        private void SetPlayerFields(Player p)
        {
            foreach (Drink.Drink d in p.Drinks)
            {
                Drinks.Add(d);
            }

            foreach (Food f in p.FoodItems)
            {
                FoodItems.Add(f);
            }

            Drink = p.Drink;
            Weapon = p.Weapon;
            Position = p.Position;
            Direction = p.Direction;
            Health = p.Stats.BaseHealth;
            NumLife = p.NumLife - 1;
        }
Example #3
0
        /////////////////////////////////////////////
        void Awake()
        {
            //Check only prefabs internal objects, the other objects will be injected by the GameManager
            if (mHandPosition == null || mPlayerModel == null)
            {
                Debug.LogError("PlayerManager: This manager is not correctly initialized.");
                enabled = false;
                return;
            }

            //Init the weapons
            foreach (GameObject weaponPrefab in mWeaponPrefabList)
            {
                GameObject    ob     = Instantiate(weaponPrefab);
                Weapon.Weapon weapon = ob.GetComponent <Weapon.Weapon>();
                if (weapon != null)
                {
                    mWeaponList.Add(weapon);
                    weapon.transform.parent        = mHandPosition;
                    weapon.transform.localPosition = Vector3.zero;
                    weapon.gameObject.SetActive(false);
                }
                else
                {
                    Debug.LogWarning("PlayerManager: found a non weapon object in prefabs list.");
                }
            }

            //Does exists weapons?
            if (mWeaponList.Count == 0)
            {
                Debug.LogError("PlayerManager: This manager is not correctly initialized.");
                enabled = false;
                return;
            }

            mWeaponList[0].gameObject.SetActive(true);
        }
Example #4
0
 private void PlayShoot(Weapon.Weapon currentWeapon)
 {
     PlaySoundFx(currentWeapon.type <= PoolObjectType.WaveBullet
         ? shootClips[Random.Range(0, shootClips.Length - 2)]
         : shootClips[shootClips.Length - 1]);
 }
Example #5
0
 public Chest(Point location, Weapon.Weapon weapon)
 {
     Location = location;
     Weapon   = weapon;
 }
Example #6
0
 public void ReactOnWeapon(Weapon.Weapon weapon, GameState gameState)
 {
     IsFrozen     = weapon.IsFrozen;
     BlockedSteps = weapon.Force;
 }
Example #7
0
        private void GenerateTreasure()
        {
            int num = RandomWrapper.Random.Next(1, 100);

            if (num < 45)
            {
                Drink = DrinkFactory.CreateRandom();
                TreasureObject = Drink;
            }
            else if (num < 90)
            {
                Food = FoodFactory.CreateRandom();
                TreasureObject = Food;
            }
            else
            {
                Weapon = WeaponFactory.CreateRandom();
                TreasureObject = Weapon;
            }
        }
Example #8
0
        public void RestoreFromeMemento(PlayerMemento memento)
        {
            Weapon = memento.Weapon;
            Drink = memento.Drink;
            Direction = memento.Direction;
            Position = memento.Position;
            Health = memento.Health;
            NumLife = memento.NumLife;

            Drinks.Clear();
            FoodItems.Clear();

            foreach (Drink.Drink d in memento.Drinks)
            {
                Drinks.Add(d);
            }

            foreach (Food f in memento.FoodItems)
            {
                FoodItems.Add(f);
            }
        }