Exemplo n.º 1
0
    void FixedUpdate()
    {
        mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        mousePos = new Vector3(Mathf.Round(mousePos.x), Mathf.Round(mousePos.y), 0);
        if (TankkiState == tila.shooting)
        {
            TykkiMeme(mousePos);
        }
        else
        {
            Tykki.gameObject.transform.rotation = transform.rotation;


            if (TankkiState == tila.moveNow)
            {
                TankkiLiike(movePos, nopeus);
                boxActive = false;
            }
            else if (TankkiState == tila.moving)
            {
                boxActive = true;
            }
            if (transform.position == movePos && TankkiState == tila.moveNow)
            {
                TankkiState = tila.moving;
                ShowMove(actionPoints, transform);
            }
        }
    }
Exemplo n.º 2
0
 bool checkMouse(Vector3 MP, tila state)
 {
     if (state == tila.moving)
     {
         if (Mathf.Abs(MP.x - transform.position.x) < 1 && Mathf.Abs(MP.y - transform.position.y) < actionPoints + 1)
         {
             return(true);
         }
         else if (Mathf.Abs(MP.x - transform.position.x) < actionPoints + 1 && Mathf.Abs(MP.y - transform.position.y) < 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else if (state == tila.shooting)
     {
         if (Mathf.Abs(MP.x - transform.position.x) < range + 1 && Mathf.Abs(MP.y - transform.position.y) < range + 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 3
0
 void backTrack()
 {
     if (backTrackPos.Count > 0)
     {
         movePos     = backTrackPos[backTrackPos.Count - 1];
         TankkiState = tila.moveNow;
         backTrackPos.RemoveAt(backTrackPos.Count - 1);
         actionPoints += (int)Mathf.Round(Vector3.Distance(movePos, transform.position));
     }
 }
Exemplo n.º 4
0
    void TankkiLiikeInit(Vector3 MP1)
    {
        if (checkMouse(MP1, TankkiState))
        {
            backTrackPos.Add(transform.position);

            movePos       = MP1;
            TankkiState   = tila.moveNow;
            actionPoints -= (int)Mathf.Round(Vector3.Distance(movePos, transform.position));
        }
    }
Exemplo n.º 5
0
    IEnumerator startTurn()
    {
        yield return(new WaitForSeconds(2));

        boxActive = true;
        DestroyWithTag("Marker");
        actionPoints += 2;
        ShowMove(actionPoints, transform);
        TankkiState = tila.moving;
        backTrackPos.RemoveRange(0, backTrackPos.Count);
    }
Exemplo n.º 6
0
    void Start()
    {
        //rb2d = GetComponent<Rigidbody2D>();
        range  = 4;
        nopeus = 0.1f;

        boxActive    = true;
        actionPoints = 3;

        ShowMove(actionPoints, transform);
        TankkiState = tila.moving;
    }
Exemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && TankkiState == tila.moving)
        {
            TankkiLiikeInit(mousePos);
        }
        if (Input.GetMouseButtonDown(0) && TankkiState == tila.shooting)
        {
            shoot(transform.position, mousePos, actionPoints);


            endMyTurn();
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            endMyTurn();
        }
        if (Input.GetKeyDown(KeyCode.Z))
        {
            backTrack();
        }
        if (Input.GetKeyDown(KeyCode.X))
        {
            if (TankkiState == tila.moving)
            {
                boxActive   = false;
                TankkiState = tila.shooting;
            }
            else if (TankkiState == tila.shooting)
            {
                boxActive = true;
                DestroyWithTag("Marker");
                ShowMove(actionPoints, transform);
                TankkiState = tila.moving;
            }
        }
    }