private void Start()
 {
     characterController = GetComponent<CharacterController>();
     movementSystem = GetComponent<PlayerInputSystem>();
     healthSystem = GetComponent<HealthSystem>();
     healthSystem.OnDied += HealthSystem_OnDied;
     weaponSystem = GetComponent<WeaponSystem>();
     weapon = GetComponent<BaseWeapon>();
     weaponModifier.SetTarget(weapon);
     weaponSystem.EquipWeapon(weapon);
     collisionSystem = GetComponent<CharacterCollisionSystem>();
     collisionSystem.OnBulletCollisionEnter.AddListener(OnBulletCollision);
 }
Exemple #2
0
    void Update()
    {
        currentWeapon = weaponSystem.GetCurrentWeapon();
        if (PauseMenu.IsOn)
        {
            return;
        }

        if (Input.GetAxisRaw("Mouse ScrollWheel") != 0)
        {
            currentWeaponIndex += (int)(Input.GetAxisRaw("Mouse ScrollWheel") * 10);
            if (currentWeaponIndex < 0)
            {
                currentWeaponIndex = 1;                         // TODO Remove hard coded value
            }
            if (currentWeaponIndex > 1)
            {
                currentWeaponIndex = 0;
            }

            Debug.Log(currentWeaponIndex);
            weaponSystem.EquipWeapon(currentWeaponIndex);
        }

        // Look for weapon input
        switch (currentWeapon.weaponType)
        {
        case WeaponConfig.WeaponType.Gun:
            if (currentWeapon.gun_FireRate <= 0f)
            {
                if (Input.GetButtonDown("Fire1"))
                {
                    ShootGun();
                }
            }
            else
            {
                if (Input.GetButtonDown("Fire1"))
                {
                    InvokeRepeating("ShootGun", 0f, 1f / currentWeapon.gun_FireRate);
                }
                else if (Input.GetButtonUp("Fire1"))
                {
                    CancelInvoke("ShootGun");
                }
            }
            break;
        }
    }
    private void Start()
    {
        weaponSystem          = GetComponent <WeaponSystem>();
        weaponSystem.isEnnemy = true;
        // create scaled weapon
        difficulty   = DifficultyScaler;
        baseWeapon   = GetComponent <BaseWeapon>();
        scaledWeapon = baseWeapon.Clone().Scale(difficulty);
        // Equip new weapon
        weaponSystem.EquipWeapon(scaledWeapon);
        aimSystem = GetComponent <BaseAimSystem>();

        healthSystem         = GetComponent <HealthSystem>();
        healthSystem.OnDied += HealthSystem_OnDied;
        collisionSystem      = GetComponent <CharacterCollisionSystem>();
        collisionSystem.OnPlayerCollisionEnter.AddListener(BodyCollider_OnEnter);
        collisionSystem.OnPlayerCollisionExit.AddListener(BodyCollider_OnExit);
        collisionSystem.OnBulletCollisionEnter.AddListener(OnBulletCollision);

        entryDetector = rangeDetection.GetComponent <OverlapCollider>();
        entryDetector.OnEnter.AddListener(EntryDetection_OnEnter);
        rangeDetection.transform.localScale = new Vector3(targettingRange, 1, targettingRange);
    }
 public void EquipWeapon(BaseWeapon.BaseWeaponModifier modifier)
 {
     modifier.SetTarget(weapon);
     weaponSystem.EquipWeapon(weapon);
 }
 public void EquipWeapon(BaseWeapon.BaseWeaponModifier weapon)
 {
     weapon.SetTarget(baseWeapon);
     scaledWeapon = baseWeapon.Clone().Scale(difficulty);
     weaponSystem.EquipWeapon(scaledWeapon);
 }