Beispiel #1
0
    public void CreateEntity(MsgSCLoadscene msg)
    {        
        if (msg.GetKind() == MsgSCLoadscene.MSG_KIND_ENEMY)
            enemymanager.Spawn(msg.GetID(), msg.GetEntityID(), msg.GetPosition(), msg.GetQuat());

        if (msg.GetKind() == MsgSCLoadscene.MSG_KIND_TRAP)
            trapmanager.CreateTrap(msg.GetID(), msg.GetEntityID(), msg.GetPosition(), msg.GetQuat());

        if (msg.GetKind() == MsgSCLoadscene.MSG_KIND_PLAYER)
        {
            if (msg.GetID() == this.userID)
                playermanager.CreatePlayer(msg.GetID(), msg.GetEntityID(),msg.GetPosition(), msg.GetQuat(), true);
            else
                playermanager.CreatePlayer(msg.GetID(), msg.GetEntityID() ,msg.GetPosition(), msg.GetQuat(), false);
        }

        if (msg.GetEntityID() == MsgSCLoadscene.MSG_KIND_TRAP)
        {
            trapmanager.CreateTrap(msg.GetID(), msg.GetEntityID(), msg.GetPosition(), msg.GetQuat());
        }
    }
Beispiel #2
0
        private void OnLeftMouseButtonPressed()
        {
            if (UserInterface.TargetEntity == null && gameMap.HoveredTile != null &&
                defenceMenu.SelectedItem != null)
            {
                var tile = gameMap.HoveredTile;
                if (defenceMenu.SelectedItem.Cost <= stats.Points
                    // Make sure the tile does not contain any objects
                    && !(wallManager.CheckContainsWall(tile, out _) ||
                         defenceManager.CheckContainsDefence(tile) ||
                         trapManager.CheckContainsTrap(tile) ||
                         enemyManager.CheckTileContainsEnemy(tile) ||
                         castle.ContainsTile(tile)))
                {
                    if (defenceMenu.SelectedItem.Name == DefenceTypes.Wall)
                    {
                        wallManager.CreateWall(gameMap.HoveredTile);
                    }
                    else if (defenceMenu.SelectedItem.Name == DefenceTypes.Cannon)
                    {
                        defenceManager.CreateDefence(DefenceTypes.Cannon, gameMap.HoveredTile);
                    }
                    else if (defenceMenu.SelectedItem.Name == DefenceTypes.Spikes)
                    {
                        trapManager.CreateTrap(DefenceTypes.Spikes, gameMap.HoveredTile);
                    }

                    stats.Points -= defenceMenu.SelectedItem.Cost;

                    if (preferences.IsAudioEnabled)
                    {
                        itemPlacedSound.Play();
                    }
                }
            }
        }