Ejemplo n.º 1
0
 public static void StartCastSkill(Skill skill)
 {
     CastSkill = skill;
     InputManager.Instance[KeyCode.Space] += StopCastSkill;
     cursorType = CursorType.CastSkill;
     CursorHandler.SetCursor(cursorType);
 }
Ejemplo n.º 2
0
        public override bool HitTest(Point p)
        {
            var item = this.GraphItem;

            if (item == null || Scene.ItemShape(item) == null)
            {
                return(false);
            }
            var sp     = Camera.ToSource(p);
            var result = DoBorderTest ?
                         Scene.ItemShape(item).IsBorderHit(sp, HitSize) :
                         Scene.ItemShape(item).IsHit(sp, HitSize);

            var anchor = Anchor.None;

            if (result && ShowGrips)
            {
                anchor = HitAnchor(p);
                if (!Resolved)
                {
                    hitAnchor = anchor;
                }
                if (!(item is TEdge))
                {
                    CursorHandler.SetCursor(anchor, result);
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
    void Update()
    {
        CursorType cursor = CursorType.Default;

        if (!EventSystem.current.IsPointerOverGameObject())
        {
            if (CastingSkill)
            {
                cursor = CursorType.CastSkill;
            }
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                int x = (int)hit.point.x;
                int y = (int)hit.point.z;
                if (hit.transform.tag == "Map")
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        if (!MapMetrics.InsideMap(y, x))
                        {
                            if (curRegion != null)
                            {
                                curRegion.Selected = false;
                            }
                            curRegion = null;
                            if (army != null)
                            {
                                DeselectArmy();
                            }
                        }
                        else
                        {
                            RegionTap(Main.regions[regionIndex[y, x]]);
                        }
                    }

                    if (Input.GetMouseButtonDown(1))
                    {
                        army?.TryMoveTo(hit.point);
                        ship?.TryMoveTo(hit.point);
                        if (curPort)
                        {
                            curPort.ShipOut(hit.point);
                        }
                    }
                }
                State      other  = null;
                IFightable target = null;
                if (hit.transform.tag == "Unit")
                {
                    Army sel = hit.transform.GetComponent <Army>();
                    if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1))
                    {
                        ArmyTap(sel, Input.GetMouseButtonDown(0));
                    }
                    other  = sel.curOwner;
                    target = sel;
                    if (CastingSkill)
                    {
                        if (CastSkill is IArmyCastable cast)
                        {
                            if (cast.CanCastOnArmy(sel))
                            {
                                cursor = CursorType.CanCastSkill;
                            }
                        }
                    }
                    else
                    {
                        if (other == curPlayer && sel != army)
                        {
                            cursor = CursorType.Select;
                        }
                    }
                }
                if (hit.transform.tag == "Ship")
                {
                    Ship sel = hit.transform.GetComponent <Ship>();
                    if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1))
                    {
                        ShipTap(sel, Input.GetMouseButtonDown(0));
                    }
                    other = sel.curOwner;
                    if (CastingSkill)
                    {
                    }
                    else
                    {
                        if (other == curPlayer && sel != ship)
                        {
                            cursor = CursorType.Select;
                        }
                    }
                }
                if (hit.transform.tag == "Town")
                {
                    Region reg = MapMetrics.regions[int.Parse(hit.transform.name)];
                    highlightRegion = reg;
                    TownTap(reg, Input.GetMouseButtonDown(0), Input.GetMouseButtonDown(1));
                    reg.bar.Active = true;
                    other          = reg.curOwner;
                    target         = reg;
                    if (CastingSkill)
                    {
                        if (CastSkill is IRegionCastable cast)
                        {
                            if (cast.CanCastOnRegion(reg))
                            {
                                cursor = CursorType.CanCastSkill;
                            }
                        }
                    }
                    else
                    {
                        if (other == curPlayer && reg != curRegion)
                        {
                            cursor = CursorType.Select;
                        }
                    }
                }
                else
                {
                    if (highlightRegion != null)
                    {
                        highlightRegion.bar.Active = false;
                    }
                }
                if (hit.transform.GetComponent <Port>())
                {
                    Port port = hit.transform.GetComponent <Port>();
                    if (Input.GetMouseButtonDown(0) && port.curOwner == curPlayer && port.Ship)
                    {
                        curPort = port;
                        DeselectShip();
                    }
                    if (Input.GetMouseButtonDown(1) && ship && port.CanshipOn(ship))
                    {
                        ship.TryMoveTo(port);
                    }
                }
                if (!CastingSkill && target != null && army != null && army.CanAttack(target, TargetType))
                {
                    switch (TargetType)
                    {
                    case DamageType.Melee:
                    case DamageType.Charge: cursor = CursorType.MeleeAttack; break;

                    case DamageType.Range: cursor = CursorType.RangeAttack; break;

                    case DamageType.Siege: cursor = CursorType.SiegeAttack; break;
                    }
                }
            }
        }
        if (curRegion == null)
        {
            MenuManager.HiddenProvinceMenu();
        }
        if (cursor != cursorType)
        {
            cursorType = cursor;
            CursorHandler.SetCursor(cursorType);
        }
    }
Ejemplo n.º 4
0
 private void Start()
 {
     CursorHandler.SetCursor(cursorType);
 }