//TODO: REWRITE ASAP
    public static Ship.GenericShip SpawnShip(SquadBuilderShip shipConfig)
    {
        //temporary
        int     id       = 1;
        Vector3 position = Vector3.zero;

        Ship.GenericShip newShipContainer = shipConfig.Instance;
        newShipContainer.InitializeGenericShip(shipConfig.List.PlayerNo, id, position);

        Roster.SubscribeSelectionByInfoPanel(newShipContainer.InfoPanel.transform.Find("ShipInfo").gameObject);
        Roster.SubscribeUpgradesPanel(newShipContainer, newShipContainer.InfoPanel);

        //TODO: Rework this
        newShipContainer.AfterGotNumberOfPrimaryWeaponAttackDice  += Rules.DistanceBonus.CheckAttackDistanceBonus;
        newShipContainer.AfterGotNumberOfPrimaryWeaponDefenceDice += Rules.DistanceBonus.CheckDefenceDistanceBonus;
        newShipContainer.AfterGotNumberOfDefenceDice += Rules.AsteroidObstruction.CheckDefenceObstructionBonus;
        newShipContainer.OnTryAddAvailableAction     += Rules.Stress.CanPerformActions;
        newShipContainer.OnTryAddAvailableAction     += Rules.DuplicatedActions.CanPerformActions;
        newShipContainer.OnMovementStart             += MovementTemplates.ApplyMovementRuler;
        newShipContainer.OnMovementStart             += MovementTemplates.CallReturnRangeRuler;
        newShipContainer.OnPositionFinish            += Rules.OffTheBoard.CheckOffTheBoard;
        newShipContainer.OnMovementExecuted          += Rules.Stress.PlanCheckStress;
        newShipContainer.AfterGetManeuverAvailablity += Rules.Stress.CannotPerformRedManeuversWhileStressed;
        newShipContainer.OnShipIsDestroyed           += Rules.TargetLocks.RegisterRemoveTargetLocksOnDestruction;

        newShipContainer.OnTokenIsAssigned            += Roster.UpdateTokensIndicator;
        newShipContainer.OnTokenIsRemoved             += Roster.UpdateTokensIndicator;
        newShipContainer.OnConditionIsAssigned        += Roster.UpdateTokensIndicator;
        newShipContainer.OnConditionIsRemoved         += Roster.UpdateTokensIndicator;
        newShipContainer.AfterAssignedDamageIsChanged += Roster.UpdateRosterHullDamageIndicators;
        newShipContainer.AfterAssignedDamageIsChanged += Roster.UpdateRosterShieldsDamageIndicators;
        newShipContainer.AfterStatsAreChanged         += Roster.UpdateShipStats;

        return(newShipContainer);
    }
Exemple #2
0
    //TODO: REWRITE ASAP
    public static Ship.GenericShip SpawnShip(ShipConfiguration shipConfig)
    {
        //temporary
        int     id       = 1;
        Vector3 position = Vector3.zero;

        Ship.GenericShip newShipContainer = (Ship.GenericShip)System.Activator.CreateInstance(System.Type.GetType(shipConfig.PilotName));
        newShipContainer.InitializeGenericShip(shipConfig.PlayerNo, id, position);

        foreach (var upgrade in shipConfig.Upgrades)
        {
            newShipContainer.InstallUpgrade(upgrade);
        }

        Roster.SubscribeActions(newShipContainer.InfoPanel.transform.Find("ShipInfo").gameObject);
        Roster.SubscribeUpgradesPanel(newShipContainer, newShipContainer.InfoPanel);

        //TODO: Rework this
        newShipContainer.AfterGotNumberOfPrimaryWeaponAttackDices  += Rules.DistanceBonus.CheckAttackDistanceBonus;
        newShipContainer.AfterGotNumberOfPrimaryWeaponDefenceDices += Rules.DistanceBonus.CheckDefenceDistanceBonus;
        newShipContainer.AfterGotNumberOfPrimaryWeaponDefenceDices += Rules.AsteroidObstruction.CheckDefenceDistanceBonus;
        newShipContainer.OnTryAddAvailableAction     += Rules.Stress.CanPerformActions;
        newShipContainer.OnTryAddAvailableAction     += Rules.DuplicatedActions.CanPerformActions;
        newShipContainer.OnMovementStart             += Rules.Collision.ClearBumps;
        newShipContainer.OnMovementStart             += MovementTemplates.ApplyMovementRuler;
        newShipContainer.OnMovementStart             += MovementTemplates.CallReturnRangeRuler;
        newShipContainer.OnPositionFinish            += Rules.OffTheBoard.CheckOffTheBoard;
        newShipContainer.OnMovementExecuted          += Rules.Stress.CheckStress;
        newShipContainer.OnMovementFinish            += Rules.AsteroidHit.CheckDamage;
        newShipContainer.AfterGetManeuverAvailablity += Rules.Stress.CannotPerformRedManeuversWhileStressed;

        newShipContainer.AfterTokenIsAssigned         += Roster.UpdateTokensIndicator;
        newShipContainer.AfterTokenIsRemoved          += Roster.UpdateTokensIndicator;
        newShipContainer.AfterAssignedDamageIsChanged += Roster.UpdateRosterHullDamageIndicators;
        newShipContainer.AfterAssignedDamageIsChanged += Roster.UpdateRosterShieldsDamageIndicators;
        newShipContainer.AfterStatsAreChanged         += Roster.UpdateShipStats;

        newShipContainer.Owner.SquadCost += shipConfig.ShipCost;

        return(newShipContainer);
    }