Exemplo n.º 1
0
        public void SetPrevWeapon()
        {
            CurrentWeapon.gameObject.SetActive(false);

            CurrentWeaponIndex--;

            if (CurrentWeaponIndex == -1)
            {
                CurrentWeaponIndex = Weapons.Length - 1;
            }

            CurrentWeapon = Weapons[CurrentWeaponIndex];

            CurrentWeapon.gameObject.SetActive(true);
        }
Exemplo n.º 2
0
        public void SetNextWeapon()
        {
            CurrentWeapon.gameObject.SetActive(false);

            CurrentWeaponIndex++;

            if (CurrentWeaponIndex == Weapons.Length)
            {
                CurrentWeaponIndex = 0;
            }

            CurrentWeapon = Weapons[CurrentWeaponIndex];

            CurrentWeapon.gameObject.SetActive(true);
        }
Exemplo n.º 3
0
        // death fx

        public void Init()
        {
            var playerSettings = GameController.SettingsSet.PlayerSettings;

            // State Machine
            StateMachine.Init();

            // Movement
            Movement = new NavMeshAgentMovement
            {
                NavMeshAgent = NavMeshAgent
            };

            // Rotation
            Rotation = new Rotation
            {
                TargetTransform = transform,
                AngularSpeed    = playerSettings.AngularSpeed
            };

            // Vitality
            Vitality = new Vitality();

            Vitality.MaxHealth = playerSettings.Health;
            Vitality.MaxArmor  = playerSettings.MaxArmor;

            Vitality.AddHealth(playerSettings.Health);
            Vitality.AddArmor(playerSettings.InitArmor);

            Vitality.OnHealthChange = StateMachine.OnHealthChange;

            // Weapons
            var weaponDescriptors = playerSettings.WeaponDescriptors;

            int weaponDescriptorsCount = weaponDescriptors.Length;

            Weapons = new TankEternalWeapon[weaponDescriptorsCount];

            CurrentWeaponIndex = playerSettings.DefaultWeaponIndex;

            for (int index = 0; index < weaponDescriptorsCount; index++)
            {
                var weaponDescriptor = weaponDescriptors[index];

                var weapon = Instantiate(weaponDescriptor.WeaponPrefab, WeaponBaseTransform);

                weapon.transform.localPosition = new Vector3(
                    weaponDescriptor.SpawnOffsetX,
                    0.0f,
                    weaponDescriptor.SpawnOffsetZ);

                weapon.BodySpriteRenderer.sortingOrder = BodySpriteRendererOrder;

                if (index != CurrentWeaponIndex)
                {
                    weapon.gameObject.SetActive(false);
                }

                weapon.Init();

                Weapons[index] = weapon;
            }

            CurrentWeapon = Weapons[CurrentWeaponIndex];

            // Nav Mesh
            NavMeshAgent.speed = playerSettings.Speed;
            //NavMeshAgent.angularSpeed = playerSettings.AngularSpeed;
        }