Exemple #1
0
        public static Ship Construct(ShipSchema schema)
        {
            List <entity.parts.Reactor>        reactors  = schema.Reactors.Select(reactorSchema => ReactorFactory.Construct(reactorSchema)).ToList();
            List <entity.parts.Shield>         shields   = schema.Shields.Select(shieldSchema => ShieldFactory.Construct(shieldSchema)).ToList();
            List <entity.parts.Weapon.IWeapon> weapons   = schema.Weapons.Select(weaponSchema => WeaponFactory.Construct(weaponSchema)).ToList();
            List <entity.parts.Engine>         engines   = schema.Engines.Select(engineSchema => EngineFactory.Construct(engineSchema)).ToList();
            List <entity.parts.CrewDeck>       crewdecks = schema.CrewDecks.Select(crewDeckSchema => CrewDeckFactory.Construct(crewDeckSchema)).ToList();

            return(new Ship(schema.Name, reactors, shields, weapons, engines, crewdecks));
        }
    //finds the ship and moves the corresponding ship
    //looks at gamestate to determine which field we are looking for
    void HandleDidChangeShipRecord(string arg1, ShipSchema arg2, IDictionary arg3, string[] arg4)
    {
        GameObject owner    = playerList.Find(p => p.GetComponent <Player> ().playerID.Equals(arg2.owner));
        GameObject ship_obj = owner.GetComponent <Player> ().shipsUnderCommand.Find(x => x.GetComponent <Ship> ().record.mongoDocument._id.Equals(arg2._id));

        Debug.Log("ship that was found when record changed: " + ship_obj.name + ", with id: " + ship_obj.GetComponent <Ship> ().record.mongoDocument._id);

        Ship shipCraft = ship_obj.GetComponent <Ship> ();

        switch (MyGameState)
        {
        case GameState.PlanningPhase:                   //looking for intended movements
            //set selectedManeuver in ship object?
            shipCraft.record.mongoDocument.selectedManeuver = arg2.selectedManeuver;
            shipCraft.phaseDutiesCompleted = true;

            break;

        case GameState.ActivationPhase:                 //looking for intended actions
            //set selectedAction in ship object?
            shipCraft.record.mongoDocument.selectedAction = arg2.selectedAction;
            shipCraft.phaseDutiesCompleted = true;

            break;

        //ship will update thier hull's damage and that will trigger this
        case GameState.CombatPhase:                             //rolling dice (probably not using in record change handler)
            Debug.LogError("ship record changed during combat phase, hull took damage... :/");
            //ships set their own phasedutiescompleted to true
            break;

        default:
            Debug.Log("ship record changed in game state: " + MyGameState.ToString());
            break;
        }



        bool nextPhase = true;          //readyToMoveOntoNextPhase;

        //checks if all players are ready to move on, if so, advanceGameState();
        foreach (GameObject ply in playerList)
        {
            foreach (GameObject shipObj in ply.GetComponent <Player>().shipsUnderCommand)
            {
                nextPhase = nextPhase && shipObj.GetComponent <Ship> ().phaseDutiesCompleted;
            }
        }

        if (nextPhase)
        {
            AdvanceGameState();
        }
    }
    void HandleDidAddShipRecord(string arg1, ShipSchema arg2)
    {
        Debug.Log("added ship: " + arg1);

        //make a record on our side from the data received
        PrizmRecord <ShipSchema> tempRecord = new PrizmRecord <ShipSchema> ();

        tempRecord.mongoDocument = arg2;

        //find the owner from the list
        GameObject owner = playerList.Find(p => p.GetComponent <Player> ().playerID.Equals(arg2.owner));

        Debug.Log("faction before giving: " + owner.GetComponent <Player> ().faction);
        //give the ship to the player
        giveShipToPlayer(owner.GetComponent <Player>(), tempRecord);
    }
Exemple #4
0
        private TreeViewItem GetTreeForShip(ShipSchema shipSchema)
        {
            var shipParent = new TreeViewItem();

            shipParent.Header     = shipSchema.Name;
            shipParent.GotFocus  += (sender, arg) => OnShipSelected?.Invoke(sender, shipSchema);
            shipParent.IsExpanded = true;
            var reactorsParent  = GetTreeForSchemas(shipSchema.Reactors.Select(item => item), "Reactors", OnDeleteReactor);
            var enginesParent   = GetTreeForSchemas(shipSchema.Engines.Select(item => item), "Engines", OnDeleteEngine);
            var shieldsParent   = GetTreeForSchemas(shipSchema.Shields.Select(item => item), "Shields", OnDeleteShield);
            var weaponsParent   = GetTreeForSchemas(shipSchema.Weapons.Select(item => item), "Weapons", OnDeleteWeapon);
            var crewdecksParent = GetTreeForSchemas(shipSchema.CrewDecks.Select(item => item), "CrewDecks", OnDeleteCrewDeck);

            shipParent.Items.Add(reactorsParent);
            shipParent.Items.Add(shieldsParent);
            shipParent.Items.Add(weaponsParent);
            shipParent.Items.Add(enginesParent);
            shipParent.Items.Add(crewdecksParent);
            return(shipParent);
        }
Exemple #5
0
 internal void Display(ShipSchema shipSchema)
 {
     _context.ShipNameTextBox.Text = shipSchema.Name;
     ConstructShipStats();
 }
Exemple #6
0
 private void _tvView_OnShipSelected(object sender, ShipSchema shipSchema)
 {
     currentlySelectedShip = null;
     _shipDetailsView.Display(shipSchema);
     currentlySelectedShip = shipSchema;
 }