Ejemplo n.º 1
0
    void Update()
    {
        int menuMove = -(int)(DungeonGameManager.GetMovementVector().y + DungeonGameManager.GetAimingVector().y);

        keyFirstPressed = menuMove != 0 && keyReleased;
        keyReleased     = menuMove == 0;

        if (keyFirstPressed)
        {
            textItems[currentSelectedItem].color = Color.white;

            currentSelectedItem = (currentSelectedItem + menuMove) % textItems.Length;
            if (currentSelectedItem < 0)
            {
                currentSelectedItem = textItems.Length - 1;
            }

            textItems[currentSelectedItem].color = Color.gray;
        }



        if (Input.GetAxis("Fire1") > 0 || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
        {
            MenuSelect();
        }
    }
Ejemplo n.º 2
0
    void FixedUpdate()
    {
        Vector2 shootDir = DungeonGameManager.GetAimingVector();

        float angleDifference = 0;

        if (shootDir.sqrMagnitude != 0) // Player is aiming with keyboard
        {
            angleDifference = (Mathf.Rad2Deg * Mathf.Atan2(shootDir.y, shootDir.x)) - transform.eulerAngles.z;
            Cursor.visible  = false;
        }
        else
        {
            Vector3 trueMousePos = Input.mousePosition;
            if (lastMousePosition == new Vector3(0, 0, float.MaxValue) || lastMousePosition != trueMousePos || Input.GetAxis("Fire1") > 0)
            {
                lastMousePosition = trueMousePos;
                Vector3 mousePosRelative = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
                float   mouseAngle       = Mathf.Rad2Deg * Mathf.Atan2(mousePosRelative.y, mousePosRelative.x);
                angleDifference = mouseAngle - transform.eulerAngles.z;

                Cursor.visible = !DungeonGameManager.LoadingNewLevel;
            }
        }

        transform.RotateAround(transform.position, Vector3.forward, angleDifference);
    }
Ejemplo n.º 3
0
 public override void OnHitDealt(MovementController opponent, bool killedOpponent)
 {
     base.OnHitDealt(opponent, killedOpponent);
     //print("player hit an enemy and killed?:" + killedOpponent);
     if (killedOpponent)
     {
         DungeonGameManager.AddScore(500);
     }
 }
Ejemplo n.º 4
0
    private void Movement()
    {
        Vector2 move = DungeonGameManager.GetMovementVector();

        if (move.sqrMagnitude == 0)
        {
            return;
        }

        Move(move.normalized);
    }
Ejemplo n.º 5
0
    void Update()
    {
        Vector2 shootDir = DungeonGameManager.GetAimingVector();



        if ((Input.GetAxis("Fire1") > 0 || shootDir.sqrMagnitude != 0) && Time.time - timeLastFired > weaponManager.Weapon.Info.cycleTime)
        {
            if (weaponManager.Weapon.CurrentAmmo == 0)
            {
                weaponManager.Reload();
                return;
            }

            timeLastFired = Time.time;
            --weaponManager.Weapon.CurrentAmmo;



            float      halfAngle        = weaponManager.Weapon.Info.inaccuracy / 2f;
            Quaternion randomQuaternion = bulletSpawnPoint.rotation;
            randomQuaternion.eulerAngles += new Vector3(0f, 0f, Random.Range(-halfAngle, halfAngle));

            GameObject bullet = Instantiate(weaponManager.Weapon.Info.bullet, bulletSpawnPoint.position, randomQuaternion);

            Rigidbody2D      rbBullet = bullet.GetComponent <Rigidbody2D>();
            BulletController bm       = bullet.GetComponent <BulletController>();

            bm.lifeTime         = weaponManager.Weapon.Info.bulletLifeTime;
            bm.damage           = weaponManager.Weapon.Info.damage;
            bm.maxCollisions    = weaponManager.Weapon.Info.penetrationDepth;
            bm.gameObject.layer = LayerMask.NameToLayer(bulletLayer);
            //bm.targetTags = new string[] {"Enemy"};

            float   randomAngle     = randomQuaternion.eulerAngles.z * Mathf.Deg2Rad;
            Vector2 directionVector = new Vector2(Mathf.Cos(randomAngle), Mathf.Sin(randomAngle)).normalized;

            rbBullet.velocity = directionVector * weaponManager.Weapon.Info.bulletSpeed; // + rbPlayer.velocity;

            //ps.Play();



            if (weaponManager.Weapon.CurrentAmmo == 0)
            {
                weaponManager.Reload();
            }
        }
    }
Ejemplo n.º 6
0
    public void MenuSelect()
    {
        switch (currentSelectedItem)
        {
        // Start new game
        case 0:
            LevelManager.LoadStartingLevel();
            break;

        // Options
        case 1:
            break;

        // Exit Game
        case 2:
            DungeonGameManager.QuitApplication();
            break;
        }
    }
Ejemplo n.º 7
0
    public event PWCFireError FireError; // Called when a reload attempt is made at a time the gun cannot reload

    #endregion

    #region monobehavior

    // Update is called once per frame
    void Update()
    {
        // To swap weapons on the arcade, pause the sim and pull up a radial selector and use joysticks to select
        // This determines what key you selected and whether to swap weapons, reload, and whatnot
        if (Input.GetKeyDown(KeyCode.Alpha1) && swapListIndex != 0)
        {
            swapList[swapListIndex].SetEnabled(false);
            swapListIndex = 0;
            swapList[swapListIndex].SetEnabled(true);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2) && swapListIndex != 1)
        {
            swapList[swapListIndex].SetEnabled(false);
            swapListIndex = 1;
            swapList[swapListIndex].SetEnabled(true);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3) && swapListIndex != 2)
        {
            swapList[swapListIndex].SetEnabled(false);
            swapListIndex = 2;
            swapList[swapListIndex].SetEnabled(true);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4) && swapListIndex != 3)
        {
            swapList[swapListIndex].SetEnabled(false);
            swapListIndex = 3;
            swapList[swapListIndex].SetEnabled(true);
        }
        else if (DungeonGameManager.SwapPressed())
        {
            swapList[swapListIndex].SetEnabled(false);
            swapListIndex++;
            if (swapListIndex == 4)
            {
                swapListIndex = 0;
            }
            swapList[swapListIndex].SetEnabled(true);
        }
        else if (DungeonGameManager.ReloadPressed() && swapList[swapListIndex].CanReload())
        {
            swapList[swapListIndex].Reload();
            // on R press, reload. If arcade, on P2 press, reload, one P2 hold, open weapon wheel
        }
        else /*if (swapList[swapListIndex].CanFire())*/
        {
            Vector2 shootDir = DungeonGameManager.GetAimingVector();

            if ((Input.GetAxis("Fire1") > 0 || shootDir.sqrMagnitude != 0))
            {
                if (swapList[swapListIndex].CanFire())
                {
                    swapList[swapListIndex].Fire(shootDir); // Player shoots
                }
                else if (swapList[swapListIndex].reloading)
                {
                    FireError();
                }
            }
        }

        // update reload bar if applicable
        if (swapList[swapListIndex].reloading)
        {
            ReloadUpdate(swapList[swapListIndex].reloading, swapList[swapListIndex].reloadProgress);
            // when reloading, put an indicator over players head that shows bullets and flashes red when you try to shoot
            // also put a bar above the ammo counter that fills up with respect to the reloadProgress
            // use events to do update the UI btw
        }
    }
Ejemplo n.º 8
0
 private void OnEnable()
 {
     master = GameObject.FindGameObjectWithTag("Master").GetComponent <DungeonGameManager>();
 }