コード例 #1
0
ファイル: PlayerController.cs プロジェクト: Bodhivb/AllForOne
    void Update()
    {
        transform.Translate(0, 0, Input.GetAxis("Vertical") * speed * Time.deltaTime / 10f);
        transform.Rotate(0, Input.GetAxis("Horizontal") * 130f * Time.deltaTime, 0);


        //Debug.DrawLine(transform.position, transform.position + transform.forward * 10);

        if (Input.GetMouseButtonDown(0) && lastShotTime + weaponCooldown < Time.time)
        {
            lastShotTime = Time.time;

            RaycastHit hit;
            if (Physics.Raycast(transform.position, transform.forward, out hit, 1.5f + weaponDistance))
            {
                //  Debug.Log("Tag to " + hit.collider.name);

                Character enemy = hit.collider.GetComponent <Character>();
                if (enemy != null)
                {
                    enemy.TakeDamage((ushort)((weaponDamage * 2f) + (defaultStrength / 5f)));
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.E) && pickUpWeapon != null)
        {
            GameControl.instance.currentTurnCharacter.OnChangedWeapon(pickUpWeapon.ShowWeapon());
            Destroy(pickUpWeapon.gameObject);
            pickUpWeapon = null;
            pickUpName   = "";
        }
    }
コード例 #2
0
    public string getWeaponType()
    {
        pickUpScript = currentWeapon.GetComponent <PickUpWeapon>();
        weaponType   = pickUpScript.weaponType;

        return(weaponType);
    }
コード例 #3
0
ファイル: PlayerController.cs プロジェクト: Bodhivb/AllForOne
 private void OnTriggerExit(Collider other)
 {
     if (other.tag == "Weapon")
     {
         pickUpWeapon = null;
         pickUpName   = "";
     }
 }
コード例 #4
0
ファイル: PlayerController.cs プロジェクト: Bodhivb/AllForOne
    private void OnTriggerEnter(Collider other)
    {
        PickUpWeapon puw = other.gameObject.GetComponent <PickUpWeapon>();

        if (other.tag == "Weapon" && puw != null)
        {
            pickUpWeapon = puw;
            pickUpName   = puw.ShowWeapon().primaryWeapon.name;
        }
    }
コード例 #5
0
 void SwapWeapon(int index)
 {
     if (Weapons[index] != null)
     {
         currentWeapon.SetActive(false);
         currentWeapon = Weapons[index];
         pickUpScript  = currentWeapon.GetComponent <PickUpWeapon>();
         weaponType    = pickUpScript.weaponType;
         positionAndRotateWeapon(weaponType);
         currentWeapon.SetActive(true);
     }
     else
     {
         currentIndex = previousIndex;
     }
 }
コード例 #6
0
ファイル: Room.cs プロジェクト: Fich019/Tap-Tap-Dungeon
    // Start is called before the first frame update.
    void Start()
    {
        audio = GetComponent <AudioSource>();

        if (!this.GetComponentInChildren <Door>())
        {
            Debug.LogError("No doors are attached to this room. Each room requires at least one door child");
        }

        // Add a NetworkRoomRelay to this Room
        _networkRoomRelay = gameObject.AddComponent <NetworkRoomRelay>();

        doors = this.GetComponentsInChildren <Door>();
        setUpDoorDirections();

        // Get the roomTrigger.
        inRoomTrigger = GetComponentInChildren <EnterRoomTrigger>().gameObject.GetComponent <BoxCollider>();


        // Get enemyCountManager.
        enemyCountManager = GameObject.FindGameObjectWithTag("EnemyCountMan").GetComponent <EnemyCountManager>();

        // Get LevelGen from parent.
        levelGenMan = GameObject.FindGameObjectWithTag("LevelGenManager").GetComponent <LevelGeneration>();

        playerPickUp = GameObject.FindGameObjectWithTag("Player").GetComponent <PickUpWeapon>();

        populateEnemiesInRoom();

        foreach (Door d in doors)
        {
            d.doorManager = levelGenMan.GetComponent <AudioSource>();
        }

        allSpawnManagers = GetComponentInChildren <EnemySpawnManager>();
    }