Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!canAttack)
        {
            return;
        }

        if (isAutomated)
        {
            return;
        }

        if (inputDevice.LeftTrigger.WasPressed && !GUN_DISABLED)
        {
            StartCoroutine(AttackCooldown());
            GameObject spawnedGun = SpawnWeapon(gun, false, false);

            WeaponFire weaponFire = spawnedGun.GetComponent <WeaponFire> ();

            weaponFire.playerInv = this.GetComponent <PlayerInventory> ();
            weaponFire.Fire(GetComponent <PlayerTeamInfo>().GetTeam());
        }
        else if (inputDevice.Action3.WasPressed)
        {
            AudioSource.PlayClipAtPoint(swordSwingSound, Camera.main.gameObject.transform.position);
            StartCoroutine(AttackCooldown());
            SpawnWeapon(sword, true, true);
        }
    }
Ejemplo n.º 2
0
    // Used to automate swing attack for tutorial demonstration
    public void Swing()
    {
        StartCoroutine(AttackCooldown());
        GameObject spawnedGun = SpawnWeapon(gun, false, false);

        WeaponFire weaponFire = spawnedGun.GetComponent <WeaponFire>();

        weaponFire.playerInv = this.GetComponent <PlayerInventory> ();
        weaponFire.Fire(GetComponent <PlayerTeamInfo>().GetTeam());
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        toPlayer     = playerGO.transform.position - bodyPart.transform.position;
        toPlayer.y   = transform.position.y;
        angleBetween = Vector3.Angle(bodyPart.transform.forward, toPlayer);

        if (Physics.Raycast(transform.position, toPlayer, out RaycastHit castHit, Mathf.Infinity, maskPlayerTerrain))
        {
            if (castHit.collider.tag == "Player")
            {
                if (angleBetween <= maxAngle)
                {
                    //for each weapon, if toPlayer.Magnitude < weaponrange, weapon.Fire()

                    foreach (GameObject indivWeapon in tankCore.weaponParts)
                    {
                        if (indivWeapon != null)
                        {
                            indivFire = indivWeapon.GetComponent <WeaponFire>();
                            if (indivFire.maxRange >= toPlayer.magnitude)
                            {
                                indivFire.Fire(playerGO.transform.position);
                            }
                        }
                    }
                }
                else
                {
                    //bodyPart.transform.rotation = Quaternion.Euler( Vector3.RotateTowards(bodyPart.transform.forward, toPlayer, tankCore.turretRotateSpeed,0));
                    //bodyPart.transform.rotation.SetLookRotation(Vector3.RotateTowards(bodyPart.transform.rotation.eulerAngles, toPlayer, tankCore.turretRotateSpeed * Time.deltaTime, 0), bodyPart.transform.up);
                    //bodyPart.transform.rotation = Quaternion.Euler(new Vector3(bodyPart.transform.rotation.eulerAngles.x, bodyPart.transform.rotation.eulerAngles.y + 1, bodyPart.transform.rotation.eulerAngles.z));
                    bodyPart.transform.rotation = Quaternion.RotateTowards(bodyPart.transform.rotation, Quaternion.LookRotation(toPlayer, Vector3.up), tankCore.turretRotateSpeed * Time.deltaTime);
                }
            }
        }
    }