Ejemplo n.º 1
0
    public static void MapCommand(MenuManager.Context context, Vector2 position)
    {
        // TODO: Replace switch with string instead of enum
        switch (MenuManager.context)
        {
        case MenuManager.Context.MapMove:
            int  distance  = (int)Grapher.ManhattanDistance(PlayerMover.instance.transform.position, position);
            bool sprinting = MenuNode.GetCurrent() == "Sprint";

            MenuManager.instance.ClearOptions();
            PlayerMover.instance.GetComponent <Navigator>().SetDestination(position, MenuNode.GetCurrent() == "Sprint");
            break;

        case MenuManager.Context.UnitSelect:
            MenuManager.instance.ClearOptions();
            RaycastHit2D hit = Physics2D.Raycast(position, Vector3.zero, 0);
            if (hit.collider == null)
            {
                Debug.Log("Tried to shoot nonexistent enemy!");
            }
            else
            {
                PlayerMover.instance.GetComponent <Shooter>().GunAttack(PlayerMover.instance.gameObject, hit.collider.gameObject);
            }
            break;
        }
    }
Ejemplo n.º 2
0
    // Generate map letters for moving to a new location
    public void MoveMenu(Vector2 startPoint)
    {
        int radius = 0;

        switch (MenuNode.GetCurrent())
        {
        case "Walk":
            // radius = Mathf.FloorToInt(PlayerMover.instance.GetComponent<FieldUnit>().ap / 2);
            break;

        case "Sprint":
            // radius = PlayerMover.instance.GetComponent<FieldUnit>().ap;
            if (Letter.morseMode)
            {
                radius = Mathf.Min(3, radius);
            }
            break;
        }

        radius = 5;

        //int rad = Mathf.FloorToInt(PlayerMover.instance.GetComponent<FieldUnit>().ap / 2);


        //List<Vector2> tilesInRange = Grapher.instance.MakeGraph(startPoint, radius);
        //List <Vector2> tilesInRange = Grapher.instance.TrimOccupied(Grapher.instance.Diamond(startPoint, radius));
        List <Vector2> tilesInRange = new List <Vector2>();

        for (int i = 0; i < tilesInRange.Count; ++i)
        {
            // Maybe call some function that trims points occupied by units
            //if(tilesInRange.Point)
            GameObject newLetter = Instantiate(letterObject, tilesInRange[i], Quaternion.identity);
            newLetter.GetComponent <Letter>().SetLetter(AssignLetter());
            currentOptions.Add(newLetter);
        }
    }