Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        //Grab the current mouse position on the screen
        Vector3 mouseOnScreen = GlobalState.GetMousePosition(mainCamera);

        //Rotates toward the mouse
        transform.eulerAngles = new Vector3(transform.eulerAngles.x,
                                            transform.eulerAngles.y,
                                            Mathf.Atan2((mouseOnScreen.y - transform.position.y), (mouseOnScreen.x - transform.position.x)) * Mathf.Rad2Deg - 90);
    }
Esempio n. 2
0
    public void CheckTarget()
    {
        if (mySpecialTarget == SpecialTarget.None)
        {
            return;
        }

        if (mySpecialTarget == SpecialTarget.Mouse)
        {
            target          = transform.Find("Target");
            target.position = GlobalState.GetMousePosition(mainCamera);
            return;
        }

        if (mySpecialTarget == SpecialTarget.Player)
        {
            target = GlobalState.FindPlayer();
            return;
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (canRestart == true)
        {
            //Restart
            if (Input.GetKeyDown(KeyCode.R) == true)
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            }
        }

        if (isDebugging == false)
        {
            return;
        }

        //Show mouse position
        if (mouseSprite != null)
        {
            if (showMouse == true)
            {
                mouseSprite.gameObject.SetActive(true);
                mouseSprite.position = GlobalState.GetMousePosition(gmScript.mainCamera);
            }
            else
            {
                mouseSprite.gameObject.SetActive(false);
            }
        }

        //Spawn enemy
        if (Input.GetKeyDown(KeyCode.P) == true)
        {
            //Spawn a row of enemy
            for (int indx = 0; indx < spawnSize; indx++)
            {
                if (randomEnemy == false)
                {
                    Transform newEnemy = Instantiate(toSpawnObjectList[enemyIndx], gmScript.objectsMaster);
                    Vector3   newPos   = transform.position;
                    newPos.x         += xDistance * indx;
                    newEnemy.position = newPos;

                    gmScript.objectsMasterScript.AddChild(newEnemy);
                }
                else
                {
                    int       tmpIndx  = Random.Range(0, toSpawnObjectList.Count);
                    Transform newEnemy = Instantiate(toSpawnObjectList[tmpIndx], gmScript.objectsMaster);
                    Vector3   newPos   = transform.position;
                    newPos.x         += xDistance * indx;
                    newEnemy.position = newPos;

                    gmScript.objectsMasterScript.AddChild(newEnemy);
                }
            }
        }

        //Increase curMana
        if (Input.GetKeyDown(KeyCode.L) == true)
        {
            myPlayer.AddRage(addManaVal);
            myPlayer.curScore += 10000;
        }

        if (Input.GetKeyDown(KeyCode.O) == true)
        {
            myPlayer.ChangeActiveSingle();
        }

        if (customTimeScale > -1)
        {
            Time.timeScale = customTimeScale;
        }

        if (Input.GetMouseButtonDown(0) == true)
        {
            if (testTarget != null)
            {
                if (moveTest == true)
                {
                    testTarget.DOMove(GlobalState.GetMousePosition(gmScript.mainCamera), testTime).SetAs(tweenParm);
                }
                if (scaleTest == true)
                {
                    testTarget.DOScale(multiplier, testTime).SetAs(tweenParm).OnComplete(DoubleMultiplier);
                    //testTarget.DOScale(transform.localScale, testTime * Time.deltaTime).SetAs(tweenParm).OnComplete(DoubleMultiplier);
                }

                if (combineTest == true)
                {
                    Vector3 rotateAngle = testTarget.eulerAngles;
                    if (rotateAngle.z <= 45 && rotateAngle.z >= -45)
                    {
                        rotateAngle.z = 180;
                    }
                    else if (rotateAngle.z > 45 && rotateAngle.z <= 135)
                    {
                        rotateAngle.z = 270;
                    }
                    else if (rotateAngle.z > 135 && rotateAngle.z <= 225)
                    {
                        rotateAngle.z = 0;
                    }
                    else
                    {
                        rotateAngle.z = 90;
                    }
                    tweenSeq = DOTween.Sequence();
                    tweenSeq.Append(testTarget.DOMove(GlobalState.GetMousePosition(gmScript.mainCamera), testTime))
                    .Join(testTarget.DORotate(rotateAngle, testTime)).Pause()
                    //.Join(testTarget.DOLookAt(Vector3.down, testTime, AxisConstraint.X, Vector3.Cross(Vector3.up, Vector3.right)))
                    ;
                    tweenSeq.SetAs(tweenParm);
                    tweenSeq.Play();
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.T) == true)
        {
            gmScript.ChangeNotificationText("Test", 2, 0);
        }

        //Formation Test
        if (Input.GetKeyDown(KeyCode.Comma) == true)
        {
            //vFormation.SummonFormation(GlobalState.GetMousePosition());
            pathFormation.SummonFormation(GlobalState.GetMousePosition(gmScript.mainCamera));
        }

        //Summon boss
        if (Input.GetKeyDown(KeyCode.Delete) == true)
        {
            Instantiate(bossToSpawn, GlobalState.GetMousePosition(gmScript.mainCamera), Quaternion.identity);
        }
    }