Esempio n. 1
0
 private void Update()
 {
     if (active && Time.timeScale != 0)
     {
         Transform enemyWarlord = aiArmy == "B" ? SM.rWarlord : SM.bWarlord;
         if (targets.Count == 0)
         {
             warlord.AttackNow(enemyWarlord.position);
         }
         else
         {
             warlord.DefendNow();
             if (Time.timeScale > 0)
             {
                 Attack(enemyWarlord.position);
             }
         }
     }
 }
Esempio n. 2
0
    private void Update()
    {
        mousePos           = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        transform.position = new Vector3(mousePos.x, mousePos.y, -5f);
        tR.startWidth      = 0.3f * uiCamera.GetComponent <Camera>().orthographicSize / 20f;
        tR.endWidth        = 0.05f * uiCamera.GetComponent <Camera>().orthographicSize / 20f;
        tR.enabled         = Input.GetMouseButton(1);
        //float k = uiCamera.GetComponent<Camera>().orthographicSize/6f;
        //transform.localScale = new Vector3(k, k, 1);
        lMouseTime = Time.time - lMouseTimer;

        if (Input.GetMouseButtonDown(0))
        {
            lMouseTimer   = Time.time;
            firstMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        }

        if (Input.GetMouseButtonUp(0))
        {
            lMouseTimer = Time.time;
            if (!lDoingLong)
            {
                lDoWhenClick();
            }
            else
            {
                lDoWhenLong();
            }
        }

        if (lDoingLong && Input.GetMouseButton(0))
        {
            DrawRect(firstMousePos, mousePos);
        }
        else
        {
            DrawRect(Vector3.zero, Vector3.zero);
        }

        if (Input.GetMouseButton(1))
        {
            rDoWhenClick();
        }

        //test
        if (Input.GetKeyDown(KeyCode.T))
        {
            Test();
        }

        //defend
        if (Input.GetKeyDown(KeyCode.D))
        {
            Defend();
        }

        if (Input.GetKeyDown(KeyCode.Q))
        {
            WarlordAttack();
        }
        if (attackWarlord)
        {
            Transform warlordTr = yourArmy == "B" ? SM.bWarlord : SM.rWarlord;
            Soldier   warlord   = warlordTr.GetComponent <Soldier>();
            warlord.AttackNow(yourArmy == "B" ? SM.rWarlord.position : SM.bWarlord.position);
        }

        //bluearmy
        if (Input.GetKeyDown(KeyCode.F1))
        {
            string     army = "B";
            GameObject off  = (GameObject)Instantiate((GameObject)Resources.Load("Officer"), new Vector3(mousePos.x, mousePos.y, -1), Quaternion.LookRotation(Vector3.forward, Vector3.right));
            off.GetComponent <Officer>().army  = army;
            off.GetComponent <Officer>().eqSet = "Sword";
            off.transform.name = army + "_Officer";
        }
        if (Input.GetKeyDown(KeyCode.F2))
        {
            string     army = "B";
            GameObject off  = (GameObject)Instantiate((GameObject)Resources.Load("Officer"), new Vector3(mousePos.x, mousePos.y, -1), Quaternion.LookRotation(Vector3.forward, Vector3.right));
            off.GetComponent <Officer>().army  = army;
            off.GetComponent <Officer>().eqSet = "Spear";
            off.transform.name = army + "_Officer";
        }
        if (Input.GetKeyDown(KeyCode.F3))
        {
            string     army = "B";
            GameObject off  = (GameObject)Instantiate((GameObject)Resources.Load("Officer"), new Vector3(mousePos.x, mousePos.y, -1), Quaternion.LookRotation(Vector3.forward, Vector3.right));
            off.GetComponent <Officer>().army  = army;
            off.GetComponent <Officer>().eqSet = "Bow";
            off.transform.name = army + "_Officer";
        }

        //redarmy
        if (Input.GetKeyDown(KeyCode.F5))
        {
            string     army = "R";
            GameObject off  = (GameObject)Instantiate((GameObject)Resources.Load("Officer"), new Vector3(mousePos.x, mousePos.y, -1), Quaternion.LookRotation(Vector3.forward, -Vector3.right));
            off.GetComponent <Officer>().army  = army;
            off.GetComponent <Officer>().eqSet = "Sword";
            off.transform.name = army + "_Officer";
        }
        if (Input.GetKeyDown(KeyCode.F6))
        {
            string     army = "R";
            GameObject off  = (GameObject)Instantiate((GameObject)Resources.Load("Officer"), new Vector3(mousePos.x, mousePos.y, -1), Quaternion.LookRotation(Vector3.forward, -Vector3.right));
            off.GetComponent <Officer>().army  = army;
            off.GetComponent <Officer>().eqSet = "Spear";
            off.transform.name = army + "_Officer";
        }
        if (Input.GetKeyDown(KeyCode.F7))
        {
            string     army = "R";
            GameObject off  = (GameObject)Instantiate((GameObject)Resources.Load("Officer"), new Vector3(mousePos.x, mousePos.y, -1), Quaternion.LookRotation(Vector3.forward, -Vector3.right));
            off.GetComponent <Officer>().army  = army;
            off.GetComponent <Officer>().eqSet = "Bow";
            off.transform.name = army + "_Officer";
        }

        //hud
        if (Input.GetKeyDown(KeyCode.H))
        {
            UIoff();
        }

        //restart
        if (Input.GetKeyDown(KeyCode.R))
        {
            Restart();
        }

        //speedUp
        if (Input.GetKeyDown(KeyCode.PageUp))
        {
            Faster();
        }

        //speedDown
        if (Input.GetKeyDown(KeyCode.PageDown))
        {
            Slower();
        }

        //pause
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Pause();
        }

        //quit
        else if (Input.GetKeyDown(KeyCode.Escape))
        {
            Menu();
        }
    }