コード例 #1
0
 private void OnPanelSelection(UiSpritePanel panel, string buttonText) => this.OnPanelSelection(panel, null, buttonText);
コード例 #2
0
    private void OnPanelSelection(UiSpritePanel panel, Sprite sprite, string buttonText)
    {
        //if (!string.IsNullOrEmpty(buttonText))
        //{
        //    if (buttonText == this.Context.Text.E_Play)
        //    {
        //        this.PlayActiveLevel();
        //    }
        //    else if (buttonText == this.Context.Text.E_ExportJson)
        //    {
        //        var result = this.File.Save(this.warehouseManager.ActiveData, true, "", false);
        //    }
        //    else if (buttonText == this.Context.Text.E_Reset)
        //    {
        //        this.PromptReset();
        //    }
        //    else if (buttonText == this.Context.Text.E_Save)
        //    {
        //        this.PromptSave();
        //    }
        //    else if (buttonText == this.Context.Text.E_Menu)
        //    {
        //        Debug.Log("Menu");
        //    }
        //    return;
        //}

        if (sprite?.name == typeof(Ground).GetCustomAttribute <SpriteAttribute>().Name)
        {
            if (this.activeGround?.occupant != null)
            {
                this.activeGround.SetOccupant(null);
            }
            else if (this.activeGridPosition.HasValue)
            {
                this.warehouseManager.AddGround(this.activeGridPosition.Value, true);
            }
            this.SetActiveGridPosition(null);
            this.SetActiveGround(null);
            return;
        }
        else if (sprite?.name == typeof(EditorDelete).GetCustomAttribute <SpriteAttribute>().Name)
        {
            if (this.activeGround != null)
            {
                this.warehouseManager.RemoveGround(this.activeGround);
            }
            this.SetActiveGridPosition(null);
            this.SetActiveGround(null);
            return;
        }
        else if (sprite?.name == typeof(Player).GetCustomAttribute <SpriteAttribute>().Name)
        {
            // we only support a single player
            var existingPlayers = this.warehouseManager.GetGroundByOccupantTypes <Player>();
            foreach (var existingPlayer in existingPlayers)
            {
                existingPlayer.SetOccupant(null);
            }
        }

        if (this.activeGround != null)
        {
            this.warehouseManager.PlaceItem(sprite, this.activeGround);
        }
        if (this.activeGridPosition.HasValue)
        {
            var newGround = this.warehouseManager.AddGround(this.activeGridPosition.Value, true);
            this.warehouseManager.PlaceItem(sprite, newGround);
        }
        this.SetActiveGridPosition(null);
        this.SetActiveGround(null);
    }
コード例 #3
0
 private void OnPanelSelection(UiSpritePanel panel, Sprite sprite) => this.OnPanelSelection(panel, sprite, null);