Beispiel #1
0
    void OnMouseDown()
    {
        UI UI = GameObject.Find("UI").GetComponent <UI>();

        if (UI.AttackMode)
        {
            UnitManage.AddEvent("Attack", UI.Selected, ActualUnit);
            UI.Cancel();
            return;
        }
        if (UI.PlayerTeam == ActualUnit.GetComponent <Unit>().Team)
        {
            if (null != UI.Selected)
            {
                PathFinding.ClearRoute(UI.Selected.GetComponent <Unit>().MoveRoute);
            }
            UI.Selected = ActualUnit;
            UI.Selected.GetComponent <Unit>().OnSelecte();
            for (int i = 2; i < gameObject.transform.parent.childCount; i += 2)
            {
                gameObject.transform.parent.GetChild(i).gameObject.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1);
            }
            GetComponent <SpriteRenderer>().color = new Color(1, 1, 0, 1);
        }
        else
        {
            Debug.Log(Message.UNIT_NOT_ON_OUR_SIDE);
        }
    }
Beispiel #2
0
 void OnMouseDown()
 {
     UI.ToggleIcon(false);
     UI.OpenSideBar(false);
     PathFinding.ClearRoute(UI.Selected.GetComponent <Unit>().MoveRoute);
     UI.MoveMode = true;
 }
Beispiel #3
0
 void OnMouseDown()
 {
     UI.ToggleIcon(false);
     UI.OpenSideBar(false);
     PathFinding.ClearRoute(UI.Selected.GetComponent <Unit>().MoveRoute);
     UI.Selected.GetComponent <Unit>().Draw(UI.Selected.GetComponent <Unit>().AttackRange, UI.Selected.GetComponent <Unit>().AttackRangeType, KeyTerm.OUTLINE_INDEX, 1, 0, 0, 0.5f);
     UI.AttackMode = true;
 }
Beispiel #4
0
 public static void ClearUnit(GameObject Unit)
 {
     Unit.GetComponent <SpriteRenderer>().color = Color.white;
     Unit.GetComponent <Unit>().Action          = KeyTerm.NONE;
     Unit.GetComponent <Unit>().MovePoint       = 0;
     Unit.GetComponent <Unit>().MoveNeed        = 0;
     PathFinding.ClearRoute(Unit.GetComponent <Unit>().MoveRoute);
     Unit.GetComponent <Unit>().MoveRoute      = null;
     Target[Unit.GetComponent <Unit>().UnitID] = null;
 }
Beispiel #5
0
 public static void Cancel()
 {
     OpenSideBar(false);
     if (null != Selected)
     {
         Selected.GetComponent <Unit>().Draw(Selected.GetComponent <Unit>().LineOfSight + 1, KeyTerm.SQUARE, KeyTerm.OUTLINE_INDEX, 1, 1, 1, 0);
         PathFinding.ClearRoute(Selected.GetComponent <Unit>().MoveRoute);
     }
     else
     {
         PathFinding.ClearRoute(Route);
     }
     Selected = null;
     ToggleIcon(false);
 }
Beispiel #6
0
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            SceneManager.LoadScene("LevelSelect");
        }
        else if (Input.GetKeyDown("e"))
        {
            Cancel();
            CurrentTurn++;
            ObjectReference.Turn.text = CurrentTurn.ToString();
            UnitManage.UpdateEvent();
            UpdateFog();
            AI.AIMove();
        }
        else if (Input.GetKeyDown("q"))
        {
            FindUnit();
        }

        if (Input.GetMouseButton(1))
        {
            Cursor.SetCursor(ResourceFile.DragCursor, Vector2.zero, CursorMode.ForceSoftware);
            DragScreen();
            Cancel();
        }
        else if (Input.GetMouseButtonUp(1))
        {
            Cursor.SetCursor(null, Vector2.zero, CursorMode.ForceSoftware);
            Check = false;
        }

        if (MoveMode)
        {
            PathFinding.ClearRoute(Route);
            if (Physics.Raycast(ObjectReference.Camera.GetComponent <Camera>().ScreenToWorldPoint(Input.mousePosition), Vector3.forward, out Hit, 11))
            {
                int MouseX = Hit.transform.parent.GetComponent <Tile>().XCor;
                int MouseY = Hit.transform.parent.GetComponent <Tile>().YCor;
                Route = PathFinding.FindPath(Selected.transform.parent.gameObject, Selected.transform.parent.gameObject, Tool.GetTile(MouseX, MouseY));
                PathFinding.DrawRoute(Route);
            }
        }
    }