Пример #1
0
    public override void Buy(MenuItemAsset item)
    {
        if (currentlyPlacing != null)
        {
            return;
        }


        currentlyPlacing = item;
    }
Пример #2
0
    public override void Buy(MenuItemAsset item)
    {
        if (!team.bankAccount.TryRemove(item.buyCost))
        {
            return;
        }
        var pos     = UnityEngine.Random.Range(0, team.baseLocation);
        var yBounds = GameManager.instance.currentGame.map.bounds.y;

        EntityManager.instance.SpawnEntity(item, team, new UnityEngine.Vector2(pos, UnityEngine.Random.Range(yBounds * -1, yBounds)), null, transform);
    }
Пример #3
0
    protected override void Update()
    {
        base.Update();
        if (Input.GetMouseButtonDown(0) && currentlyPlacing != null)
        {
            if (!team.bankAccount.TryRemove(currentlyPlacing.buyCost))
            {
                teamUiRenderer.DisplayPrompt($"You can't afford {currentlyPlacing.buyCost}!", Color.red);
                return;
            }
            PointerEventData pointerData = new PointerEventData(EventSystem.current)
            {
                pointerId = -1,
            };

            pointerData.position = Input.mousePosition;

            List <RaycastResult> results = new List <RaycastResult>();

            EventSystem.current.RaycastAll(pointerData, results);
            if (results.Count > 0)
            {
                return; //There are UI elements there.
            }
            var pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            if (!team.Contains(pos))
            {
                return;
            }

            EntityManager.instance.SpawnEntity(currentlyPlacing, team, pos);
        }
        if (Input.GetKey(KeyCode.Escape) && currentlyPlacing != null)
        {
            currentlyPlacing = null;
        }
    }
Пример #4
0
 public abstract void Buy(MenuItemAsset item);