private void Throwing()
    {
        throwingWeapon.transform.SetParent(cantUseWeaponParent);

        // 집중상태에서는 클릭한 좌표로 던진다.
        if (isFocusMode)
        {
            isFocusMode = false;

            float magnitude = Vector3.Distance(crossHair.CrossHairWorldPosition(), transform.position);
            throwingWeapon.Throw(transform.forward, magnitude * 39.5f);
        }
        // 집중상태가 아닌 경우 적당한 힘으로 전방에 던진다.
        else
        {
            throwingWeapon.Throw(transform.forward, 200);
        }

        // slot을 비운다.
        weaponSlotManager.ResetWeapon();

        // 현재 무기 정보 초기화
        conWeaponType  = Weapontype.None;
        throwingWeapon = null;
    }
Esempio n. 2
0
 public void setWeapon(int n)
 {
     if (n == 0)
     {
         loadedWeapon = Resources.Load(ResourcePathConstants.MACHINE_GUN) as GameObject;
         weapontype   = Weapontype.MACHINE_GUN;
         speed        = 1;
         Debug.Log("Machine Gun loaded");
         FindObjectOfType <AudioManager>().Play("weapon_switch");
     }
     else if (n == 1)
     {
         loadedWeapon = Resources.Load(ResourcePathConstants.MISSILE) as GameObject;
         weapontype   = Weapontype.MISSILE;
         speed        = 5;
         Debug.Log("Rocket Launcher loaded");
         FindObjectOfType <AudioManager>().Play("weapon_switch");
     }
     else if (n == 2)
     {
         loadedWeapon = Resources.Load(ResourcePathConstants.LASER) as GameObject;
         weapontype   = Weapontype.LASER;
         Debug.Log("Laser loaded");
         FindObjectOfType <AudioManager>().Play("weapon_switch");
     }
 }
    private void DisarmWeapon()
    {
        Transform weapon;

        WeaponScript conWeapon = GetWeaponScript();

        // 현재 무기를 가지고 있다면
        if (conWeaponType != Weapontype.None)
        {
            // 무기를 바닥에 놓는다.
            weapon = handlingWeaponParent.GetChild(0);
            weapon.SetParent(droppedWeaponParent);
            weapon.position = transform.position + transform.forward * 0.5f;
            weapon.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0);

            // 무기를 최초 상태로 초기화
            conWeapon.ResetOwner();
            conWeapon.ChangeToDrop();
            weaponAudio.clip = punchClip;

            // 현재 무기 상태를 없음 으로 기록.
            conWeaponType = Weapontype.None;
            SetWeaponInfo(null);
        }
    }
Esempio n. 4
0
    private void OnCollisionEnter(Collision collision)
    {
        switch (collision.gameObject.tag)
        {
        case "superPunch":
            weapontype       = Weapontype.superPunch;
            weaponImg.sprite = weapons[1];
            Destroy(collision.gameObject);
            break;

        case "knife":
            weapontype       = Weapontype.knife;
            weaponImg.sprite = weapons[2];
            Destroy(collision.gameObject);
            break;

        case "slash":
            weapontype       = Weapontype.slash;
            weaponImg.sprite = weapons[3];
            Destroy(collision.gameObject);
            break;

        case "gun":
            weapontype       = Weapontype.gun;
            weaponImg.sprite = weapons[4];
            Destroy(collision.gameObject);
            break;

        case "Lava":
            EndTurn();
            Die();
            break;
        }
    }
    private void WeaponChangeToBellyWeapon()
    {
        Transform weapon;

        // 현재 무기를 가지고 있다면
        if (conWeaponType != Weapontype.None)
        {
            // 무기를 배로 이동
            weapon = handlingWeaponParent.GetChild(0);
            weapon.SetParent(bellyWeaponParent);
            weapon.localPosition = Vector3.zero;
            weapon.localRotation = Quaternion.Euler(0, 0, 0);
            weapon.GetComponent <WeaponScript>().ChangeToBelly();
        }

        // 선택한 slot에 저장되어있는 무기를 가져온다.
        WeaponScript newWeapon = weaponSlotManager.GetWeapon(conWeaponIndex);

        // 가져오려는 slot에 물건이 없다면..
        if (newWeapon == null)
        {
            conWeaponType    = Weapontype.None;
            weaponAudio.clip = punchClip;
        }
        else
        {
            // 무기를 등에서 얻는다면..
            if (newWeapon.weaponType == Weapontype.Swing || newWeapon.weaponType == Weapontype.Shooting)
            {
                conWeaponType = Weapontype.None;

                // 등에서 무기를 얻는 애니메이션을 실행
                if (weaponSlotManager.GetWeapon(conWeaponIndex).weaponType == Weapontype.Throwing)
                {
                    animator.SetTrigger("WeaponChangeToBellyWeapon");
                }
                else
                {
                    animator.SetTrigger("WeaponChangeToBackWeapon");
                }
            }
            // 무기를 배에서 얻는다면..
            else
            {
                // 무기를 손으로 이동
                weapon = weaponSlotManager.GetWeapon(conWeaponIndex).transform;
                weapon.SetParent(handlingWeaponParent);
                weapon.localPosition = Vector3.zero;
                weapon.localRotation = Quaternion.Euler(0, 0, 0);
                weapon.GetComponent <WeaponScript>().ChangeToEquiped();

                // 새로운 무기로 정보를 변경
                conWeaponType = newWeapon.weaponType;
                SetWeaponInfo(newWeapon);
                weaponAudio.clip = newWeapon.weaponUsingSound;
            }
        }
    }
Esempio n. 6
0
    public void initWeapon()
    {
        GameObject wep = Resources.Load(ResourcePathConstants.MACHINE_GUN) as GameObject;

        loadedWeapon = wep;
        weapontype   = Weapontype.MACHINE_GUN;
        speed        = 1;
        Debug.Log("Machine Gun loaded");
    }
    void OnWeaponTypeClick(Weapontype weapontype)
    {
        playerprefz.SetCurrentWeaponCategory((int)weapontype);
        CurrentWeapon = WeaponSpecs[(int)weapontype];
        currentitem   = playerprefz.getCurrentGun();
        for (int i = 0; i < WeaponSpecs.Length; i++)
        {
            WeaponSpecs[i].BTN_TypeSelect.GetComponent <Image>().color = Color.white;
        }
        CurrentWeapon.BTN_TypeSelect.GetComponent <Image>().color = CurrentWeapon.ClickedColor;

        WeaponItemsUpdate();
    }
Esempio n. 8
0
 private void chooseWeapon()
 {
     if (laserAmount > 0)
     {
         loadedWeapon = Resources.Load(ResourcePathConstants.LASER) as GameObject;
         weapontype   = Weapontype.LASER;
     }
     else if (missileAmount > 0)
     {
         loadedWeapon    = Resources.Load(ResourcePathConstants.MISSILE) as GameObject;
         weapontype      = Weapontype.MISSILE;
         projectileSpeed = 5;
     }
     else
     {
         loadedWeapon    = Resources.Load(ResourcePathConstants.MACHINE_GUN) as GameObject;
         weapontype      = Weapontype.MACHINE_GUN;
         projectileSpeed = 1;
     }
 }
Esempio n. 9
0
        }//End Update

        /// <summary>
        /// Allows player choose which state of gun they want to use
        /// </summary>
        private void CycleWeapons()
        {
            // bool wantsToSwitch = Input.GetButtonDown("CycleWeapons");

            // if (!wantsToSwitch) return;

            float cycleInput = Input.GetAxisRaw("CycleWeapons");

            int cycleDir = 0;

            if (cycleInput < 0)
            {
                cycleDir = -1;
            }
            if (cycleInput > 0)
            {
                cycleDir = 1;
            }

            if (previousCycleDir == 0)
            {
                int index = (int)currentWeapon + cycleDir;

                //if (cycle > 0) index++;
                //if (cycle < 0) index--;

                int max = System.Enum.GetNames(typeof(Weapontype)).Length - 1;

                if (index < 0)
                {
                    index = max;
                }
                if (index > max)
                {
                    index = 0;
                }

                currentWeapon = (Weapontype)index;
            }
            previousCycleDir = cycleDir;
        }
Esempio n. 10
0
    private void ArmWeapon()
    {
        Transform weapon;

        WeaponScript conWeapon = GetWeaponScript();

        // 현재 무기를 가지고 있다면
        if (conWeaponType != Weapontype.None)
        {
            // 사용하던 무기를 바닥에 놓는다.
            weapon = conWeapon.GetComponent <Transform>();
            weapon.SetParent(droppedWeaponParent);
            weapon.position = transform.position + transform.forward * 0.5f;
            weapon.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0);

            // 무기를 최초 상태로 초기화
            conWeapon.ResetOwner();
            conWeapon.ChangeToDrop();
        }

        // 플레이어가 가지는 무기 정보를 새로운 무기 정보로 변경
        conWeapon     = DropObjectScript.dropObject;
        conWeaponType = conWeapon.weaponType;
        SetWeaponInfo(conWeapon);
        weaponAudio.clip = conWeapon.weaponUsingSound;

        // 무기의 상태 및 정보를 플레이어가 가지는 상태로 변경
        conWeapon.SetOwner(this);
        conWeapon.ChangeToEquiped();

        // 새로운 무기를 손으로 이동
        weapon = conWeapon.transform;
        weapon.SetParent(handlingWeaponParent, true);
        weapon.localPosition = Vector3.zero;
        weapon.localRotation = Quaternion.Euler(0, 0, 0);
    }
Esempio n. 11
0
    private void AttackEnd()
    {
        if (canContinuousAttack && !isFinishAttackDelay)
        {
            // 무기 타입에 따라..
            switch (conWeaponType)
            {
            // 무기가 없다.(주먹질)
            case Weapontype.None:

                // 앞으로 조금 이동
                attackMovingCoroutine = StartCoroutine(AttackMovingCoroutine(0.3f, false));

                // 공격
                animator.SetTrigger("Punch");

                break;


            // 몽둥이, 검 등의 무기
            case Weapontype.Swing:

                // 무기 파괴 유무 검사
                if (swingWeapon.conUsing <= 0)
                {
                    // 파괴 이펙트 생성
                    GameObject temp = ObjectPullManager.Instance.GetInstanceByName("WeaponBreaking");
                    temp.transform.position = swingWeapon.transform.position + temp.transform.position;
                    temp.SetActive(true);

                    // 무기 파괴
                    swingWeapon.transform.SetParent(cantUseWeaponParent);
                    swingWeapon.transform.localPosition = Vector3.zero;
                    swingWeapon.gameObject.SetActive(false);
                    swingWeapon.DestroyWeapon();
                    swingWeapon = null;

                    // 현재 가지는 무기 정보 초기화
                    conWeaponType = Weapontype.None;

                    // slot을 비운다.
                    weaponSlotManager.ResetWeapon();

                    if (FinishAttackDelayCoroutine == null)
                    {
                        FinishAttackDelayCoroutine = StartCoroutine(AttackFinishCoroutine());
                    }

                    attackHitArea.CloseHitAreaOff();

                    // 이동 시작
                    MoveStart();
                }
                else
                {
                    // 그 외엔 조금 이동
                    attackMovingCoroutine = StartCoroutine(AttackMovingCoroutine(0.5f, false));

                    // 공격
                    animator.SetTrigger("Swing");
                }
                break;
            }
        }
        // 공격 마무리
        else
        {
            // 무기 타입에 따라..
            switch (conWeaponType)
            {
            // 무기가 없다.(주먹질)
            case Weapontype.None:

                if (FinishAttackDelayCoroutine != null)
                {
                    FinishAttackDelayCoroutine = StartCoroutine(AttackFinishCoroutine());
                }

                // 공격 판정 범위 Off
                attackHitArea.CloseHitAreaOff();

                // 이동 시작
                MoveStart();

                break;


            // 몽둥이, 검 등의 무기
            case Weapontype.Swing:

                if (swingWeapon.conUsing <= 0)
                {
                    // 파괴 이펙트 생성
                    GameObject temp = ObjectPullManager.Instance.GetInstanceByName("WeaponBreaking");
                    temp.transform.position = swingWeapon.transform.position + temp.transform.position;
                    temp.SetActive(true);

                    // 무기 파괴
                    swingWeapon.transform.SetParent(cantUseWeaponParent);
                    swingWeapon.transform.localPosition = Vector3.zero;
                    swingWeapon.gameObject.SetActive(false);
                    swingWeapon.DestroyWeapon();
                    swingWeapon = null;

                    // 현재 가지는 무기 정보 초기화
                    conWeaponType = Weapontype.None;

                    // slot을 비운다.
                    weaponSlotManager.ResetWeapon();
                }
                else
                {
                    // Trail Off
                    swingWeapon.TrailOff();
                }

                if (FinishAttackDelayCoroutine == null)
                {
                    FinishAttackDelayCoroutine = StartCoroutine(AttackFinishCoroutine());
                }

                // 공격 판정 범위 Off
                attackHitArea.CloseHitAreaOff();

                // 이동 시작
                MoveStart();

                break;

            // 총 등의 무기
            case Weapontype.Shooting:

                shootingWeapon.ContinuousAttackEnd();

                // 이동 시작
                MoveStart();

                break;
            }
        }
    }