Exemplo n.º 1
0
    void Start()
    {
        currentState   = StructureState.EMPTY;
        structureImage = GameObject.Find("StructureImage");

        kumaraText  = GameObject.Find("KumaraDeduction").GetComponent <Text> ();
        flaxText    = GameObject.Find("FlaxDeduction").GetComponent <Text> ();
        kauriText   = GameObject.Find("KauriDeduction").GetComponent <Text> ();
        moaText     = GameObject.Find("MoaDeduction").GetComponent <Text> ();
        pounamuText = GameObject.Find("PounamuDeduction").GetComponent <Text> ();

//		paLogic = GameObject.Find ("BuildPa").GetComponent<PaLogic> ();
//		roadLogic = GameObject.Find ("BuildRoad").GetComponent<RoadLogic> ();
//		campLogic = GameObject.Find ("BuildCamp").GetComponent<CampLogic> ();
    }
Exemplo n.º 2
0
 void CheckPlayerResources()
 {
     if (currentPlayer.GetComponent <NewPlayer>().data.StartingCamps > 0)
     {
         currentState = StructureState.CAMP;
     }
     else if (currentPlayer.GetComponent <NewPlayer>().data.StartingRoads > 0)
     {
         currentState = StructureState.ROAD;
     }
     else if (currentPlayer.GetComponent <NewPlayer>().StartingPhase())
     {
         currentState = StructureState.EMPTY;
     }
 }
    //Constructor
    public Structure(PhantomConstruction Prototype)
    {
        //Consturction
        //Bricks = new List<GameObject>();
        BWorkbenches = new List <Workbench>();
        //XmlDocument _BuildingXMLDescription = new XmlDocument();
        //XmlNodeList _CoordinatesDescription;
        //Vector3 _Coordinates;
        MasterObject = new GameObject();

        //Defenition
        State    = StructureState.New;
        id       = Structures.BuildingID;
        Version  = 0;
        Rotation = Prototype.Rotation;
        TypeName = Prototype.TypeName;

        //Processing
        MasterObject.name = TypeName + ":" + id.ToString();
        MasterObject.transform.SetParent(Map.GetBrick(Prototype.MasterObject.transform.position).gameObject.transform.parent);
        MasterObject.transform.position = Prototype.MasterObject.transform.position;
    }
Exemplo n.º 4
0
        public void FinishChecking(IWIBase iwiBase)
        {
            mLoadingStackItem = false;

            if (iwiBase == null)
            {
                FinishedChecking = true;
                HasCompleted     = false;
                return;
            }

            System.Object structureStateObject = null;
            if (iwiBase.GetStateOf <Structure> (out structureStateObject))
            {
                StructureState structureState = (StructureState)structureStateObject;
                HasCompleted = Flags.Check((uint)LoadState, (uint)structureState.LoadState, Flags.CheckType.MatchAll);
                if (HasCompleted)
                {
                    Status |= MissionStatus.Completed;
                }
            }
            FinishedChecking = true;
        }
Exemplo n.º 5
0
        public static string GetIconProperties(
            StackItem stackitem,
            LocationState ls,
            RevealableState rs,
            VisitableState vs,
            ref string iconName,
            ref MapIconStyle iconStyle,
            ref MapLabelStyle labelStyle,
            ref Color32 iconColor,
            ref Vector3 iconOffset)
        {
            iconName   = "MapIconOutpost";
            iconStyle  = MapIconStyle.Small;
            labelStyle = MapLabelStyle.None;
            iconColor  = Color.grey;
            bool checkShingleState   = false;
            bool checkStructureState = false;

            switch (ls.Type)
            {
            case "City":
                if (stackitem.Props.Local.ActiveRadius > Globals.CityMinimumRadius)
                {
                    iconName   = "MapIconCity";
                    iconStyle  = MapIconStyle.Large;
                    labelStyle = MapLabelStyle.MouseOver;
                }
                else if (stackitem.Props.Local.ActiveRadius > Globals.TownMinimumRadius)
                {
                    iconStyle  = MapIconStyle.Medium;
                    iconName   = "MapIconTown";
                    labelStyle = MapLabelStyle.MouseOver;
                }
                else
                {
                    iconName   = "MapIconOutpost";
                    iconStyle  = MapIconStyle.Small;
                    labelStyle = MapLabelStyle.MouseOver;
                }
                break;

            case "CapitalCity":
                iconName   = "MapIconCapitalCity";
                iconStyle  = MapIconStyle.AlwaysVisible;
                labelStyle = MapLabelStyle.AlwaysVisible;
                break;

            case "Woods":
                iconName   = "MapIconWoods";
                iconStyle  = MapIconStyle.Large;
                labelStyle = MapLabelStyle.MouseOver;
                break;

            case "Den":
                iconName   = "MapIconAnimalDen";
                iconStyle  = MapIconStyle.Medium;
                labelStyle = MapLabelStyle.MouseOver;
                break;

            case "CrossRoads":
                iconName   = "MapIconCrossRoads";
                iconStyle  = MapIconStyle.AlwaysVisible;
                labelStyle = MapLabelStyle.MouseOver;
                break;

            case "WayStone":
                iconName   = "MapIconWayStone";
                iconStyle  = MapIconStyle.Small;
                labelStyle = MapLabelStyle.MouseOver;
                break;

            case "Shingle":
            case "Residence":
                iconName            = "MapIconStructure";
                iconStyle           = MapIconStyle.Small;
                labelStyle          = MapLabelStyle.MouseOver;
                checkShingleState   = true;
                checkStructureState = true;
                break;

            case "Shop":
                iconName            = "MapIconShop";
                iconStyle           = MapIconStyle.Small;
                labelStyle          = MapLabelStyle.MouseOver;
                checkShingleState   = true;
                checkStructureState = true;
                break;

            case "Tavern":
            case "Bar":
                iconName            = "MapIconTavern";
                iconStyle           = MapIconStyle.Small;
                labelStyle          = MapLabelStyle.MouseOver;
                checkShingleState   = true;
                checkStructureState = true;
                break;

            case "Inn":
                iconName            = "MapIconInn";
                iconStyle           = MapIconStyle.Small;
                labelStyle          = MapLabelStyle.MouseOver;
                checkShingleState   = true;
                checkStructureState = true;
                break;

            case "Landmark":
                iconName   = "MapIconLandmark";
                iconStyle  = MapIconStyle.AlwaysVisible;
                labelStyle = MapLabelStyle.MouseOver;
                break;

            case "HouseOfHealing":
                iconName   = "MapIconHouseOfHealing";
                iconStyle  = MapIconStyle.Large;
                labelStyle = MapLabelStyle.MouseOver;
                break;

            case "Gateway":
                iconName   = "MapIconGateway";
                iconStyle  = MapIconStyle.Large;
                labelStyle = MapLabelStyle.MouseOver;
                break;

            case "Cemetary":
                iconName   = "MapIconCemetary";
                iconStyle  = MapIconStyle.Medium;
                labelStyle = MapLabelStyle.MouseOver;
                break;

            case "Dungeon":
                iconName   = "MapIconCave";
                iconStyle  = MapIconStyle.Medium;
                labelStyle = MapLabelStyle.MouseOver;
                break;

            case "Campsite":
                iconName   = "MapIconCampsite";
                iconStyle  = MapIconStyle.Medium;
                labelStyle = MapLabelStyle.MouseOver;
                break;

            case "District":
            case "CrossStreet":
            default:
                iconStyle  = MapIconStyle.None;
                labelStyle = MapLabelStyle.Descriptive;
                break;
            }

            if (checkStructureState)
            {
                StructureState ss = null;
                if (stackitem.GetStateData <StructureState> (out ss))
                {
                    iconOffset.x      = -ss.PrimaryBuilderOffset.Position.x;
                    iconOffset.y      = -ss.PrimaryBuilderOffset.Position.z;
                    checkShingleState = true;
                }
            }

            if (checkShingleState)
            {
                ShingleState sh = null;
                if (stackitem.GetStateData <ShingleState> (out sh))
                {
                    switch (sh.PropertyStatus)
                    {
                    case PropertyStatusType.OwnedByPlayer:
                        labelStyle = MapLabelStyle.AlwaysVisible;
                        iconColor  = Colors.Get.MessageSuccessColor;
                        break;

                    case PropertyStatusType.ForSale:
                        iconColor = Colors.Get.MessageInfoColor;
                        break;

                    case PropertyStatusType.Destroyed:
                        iconColor = Colors.Get.MessageDangerColor;
                        break;

                    case PropertyStatusType.Abandoned:
                        iconColor = Colors.Get.MessageWarningColor;
                        break;

                    default:
                        break;
                    }
                }
            }

            if (rs.UnknownUntilVisited)
            {
                if (vs == null || vs.NumTimesVisited <= 0)
                {
                    iconName = "MapIconUnknown";
                }
            }
            return(iconName);
        }
Exemplo n.º 6
0
        private void InitializeLoadState(List <ISaveState> LoadFromState)
        {
            Dictionary <Guid, Interior> interiorForObjMap = new Dictionary <Guid, Interior>(); // key is the interiorObjFor and val is the interior that belongs to this obj

            foreach (ISaveState objState in LoadFromState)
            {
                // Interiors are deserialized first since they were serialized first
                if (objState.GetType() == typeof(InteriorState))
                {
                    InteriorState its = (InteriorState)objState;
                    Interior      i   = DeserializeInterior(its);
                    interiorForObjMap.Add(its.interiorForId, i);
                    BoundingBoxLocations.interiorMap.Add(i.interiorId, i);
                }

                if (objState.GetType() == typeof(PlayerState))
                {
                    PlayerState ps = (PlayerState)objState;
                    player.location  = ps.location;
                    player.inventory = DeserializeInventory(ps.inventory);
                    player.inHand    = (HandHeld)DeserializeInventoryItem(ps.inHandItemKey);

                    if (ps.playerInInteriorId == Guid.Empty)
                    {
                        player.playerOnShip     = null;
                        player.playerInInterior = null;
                    }
                    else
                    {
                        player.entranceLoc = ps.interiorEntranceLocation;
                        // check if the interior already exists
                        foreach (KeyValuePair <Guid, Interior> interior in BoundingBoxLocations.interiorMap)
                        {
                            if (ps.playerInInteriorId == interior.Key)
                            {
                                player.playerInInterior = interior.Value;
                                break;
                            }
                        }
                    }

                    player.onShip    = ps.onShip;
                    player.regionKey = ps.region;
                    player.health    = ps.health;
                    UpdateOrder.Add(player);
                }

                else if (objState.GetType() == typeof(NpcState))
                {
                    NpcState npcs = (NpcState)objState;
                    Npc      npc  = (Npc)DeserializeModel(npcs.objKey, npcs);
                    npc.location  = npcs.location;
                    npc.inventory = DeserializeInventory(npcs.inventory);

                    if (npcs.npcInInteriorId == Guid.Empty)
                    {
                        npc.npcInInterior = null;
                    }
                    else
                    {
                        // THIS SHOULD NEVER RUN BECAUSE NPCS THAT ARE IN INTERIORS ARE DESERIALIZED ELSEWHERE

                        // check if the interior already exists
                        foreach (KeyValuePair <Guid, Interior> interior in BoundingBoxLocations.interiorMap)
                        {
                            if (npcs.npcInInteriorId == interior.Key)
                            {
                                npc.npcInInterior = interior.Value;
                                break;
                            }
                        }
                    }

                    npc.onShip    = npcs.onShip;
                    npc.regionKey = npcs.region;
                    npc.health    = npcs.health;
                    UpdateOrder.Add(npc);
                }

                else if (objState.GetType() == typeof(ShipState))
                {
                    ShipState ss = (ShipState)objState;
                    Ship      s  = (Ship)DeserializeModel(ss.objKey, ss);
                    UpdateOrder.Add(s);
                }

                else if (objState.GetType() == typeof(StructureState))
                {
                    StructureState ss = (StructureState)objState;
                    Structure      s  = (Structure)DeserializeModel(ss.objKey, ss);
                    UpdateOrder.Add(s);
                }

                else if (objState.GetType() == typeof(WeatherSaveState))
                {
                    WeatherSaveState wss = (WeatherSaveState)objState;
                    WeatherState.currentLightIntensity = wss.currentLightIntensity;
                    WeatherState.currentMsOfDay        = wss.currentMsOfDay;
                    WeatherState.sunAngleX             = wss.sunAngleX;
                    WeatherState.shadowTransparency    = wss.shadowTransparency;
                    WeatherState.totalDays             = wss.nDays;
                    WeatherState.weatherDuration       = wss.weatherDuration;
                    WeatherState.msThroughWeather      = wss.msThroughWeather;
                    WeatherState.rainState             = wss.rainState;
                    WeatherState.rainIntensity         = wss.rainIntensity;
                    WeatherState.lightning             = wss.lightning;

                    // set the rain
                    for (int i = 0; i < WeatherState.rainIntensity; i++)
                    {
                        WeatherState.rain.Add(new RainDrop(_content, _graphics));
                    }
                }

                else if (objState.GetType() == typeof(OnGroundState))
                {
                    OnGroundState ogs = (OnGroundState)objState;
                    Sprite        sp  = null;
                    if (ogs.inventoryItem)
                    {
                        InventoryItem ii = DeserializeInventoryItem(ogs.objKey);
                        ii.amountStacked = ogs.amountStacked;
                        ii.onGround      = true;
                        sp = ii;
                    }
                    else
                    {
                        sp = DeserializeModel(ogs.objKey, objState);
                    }
                    sp.location  = ogs.location;
                    sp.regionKey = ogs.region;

                    ItemUtility.ItemsToUpdate.Add(sp);
                }
            }

            // go through newly created world state and set any interiors for the object that owns that interior
            foreach (Sprite sp in UpdateOrder)
            {
                if (sp is IHasInterior)
                {
                    IHasInterior hasInterior   = (IHasInterior)sp;
                    Guid         interiorForId = hasInterior.GetInteriorForId();

                    if (sp is IShip)
                    {
                        Ship sh = (Ship)sp;
                        sh.shipInterior = interiorForObjMap[interiorForId];
                    }
                    else if (sp is IStructure)
                    {
                        Structure st = (Structure)sp;
                        st.structureInterior = interiorForObjMap[interiorForId];
                    }

                    interiorForObjMap[interiorForId].interiorForObj = sp;
                }
            }

            // set player's current ship, the interior will be the ships interior
            if (player.onShip)
            {
                player.playerOnShip = (Ship)BoundingBoxLocations.interiorMap[player.playerInInterior.interiorId].interiorForObj;
            }
        }
Exemplo n.º 7
0
        public void SaveGameState()
        {
            // Create the save state
            List <ISaveState>           SaveState   = new List <ISaveState>();
            Dictionary <Interior, Guid> interiorMap = new Dictionary <Interior, Guid>();

            // save all interior states
            foreach (var interior in BoundingBoxLocations.interiorMap)
            {
                InteriorState its = SerializeInterior(interior.Value);
                interiorMap.Add(interior.Value, interior.Key);
                SaveState.Add(its);
            }

            // save the world state
            foreach (Sprite sp in UpdateOrder)
            {
                // PLAYER
                if (sp.GetType().BaseType == typeof(Gusto.Models.Animated.PlayerPirate))
                {
                    PlayerState state = new PlayerState();
                    state.team     = player.teamType;
                    state.location = player.location;
                    state.interiorEntranceLocation = player.entranceLoc;
                    state.region    = player.regionKey;
                    state.inventory = SerializeInventory(player.inventory);
                    state.onShip    = player.onShip;
                    // set the player in their interior if they save while on ship
                    if (player.onShip)
                    {
                        player.playerInInterior = player.playerOnShip.shipInterior;
                    }

                    if (player.playerInInterior != null)
                    {
                        state.playerInInteriorId = interiorMap[player.playerInInterior]; // interiorMap should be full since we ran interiors before this
                    }
                    else
                    {
                        state.playerInInteriorId = Guid.Empty;
                    }

                    state.inHandItemKey = player.inHand.itemKey;
                    state.health        = player.health;
                    SaveState.Add(state);
                }

                else if (sp.GetType().BaseType == typeof(Gusto.Models.Animated.Npc))
                {
                    Npc      npc   = (Npc)sp;
                    NpcState state = new NpcState();
                    state.team      = npc.teamType;
                    state.location  = npc.location;
                    state.objKey    = npc.bbKey;
                    state.region    = npc.regionKey;
                    state.inventory = SerializeInventory(npc.inventory);
                    state.onShip    = npc.onShip;

                    state.npcInInteriorId = Guid.Empty;
                    state.health          = npc.health;
                    SaveState.Add(state);
                }

                else if (sp.GetType().BaseType == typeof(Gusto.Models.Animated.Ship))
                {
                    Ship      sh    = (Ship)sp;
                    ShipState state = new ShipState();
                    state.team            = sh.teamType;
                    state.location        = sh.location;
                    state.region          = sh.regionKey;
                    state.objKey          = sh.bbKey;
                    state.actionInventory = SerializeInventory(sh.actionInventory);
                    state.playerAboard    = sh.playerAboard;
                    state.anchored        = sh.anchored;
                    state.health          = sh.health;
                    state.shipId          = sh.GetInteriorForId();
                    SaveState.Add(state);
                }

                else if (sp.GetType().BaseType == typeof(Gusto.Models.Animated.Structure))
                {
                    Structure      st    = (Structure)sp;
                    StructureState state = new StructureState();
                    state.team        = st.teamType;
                    state.location    = st.location;
                    state.region      = st.regionKey;
                    state.objKey      = st.bbKey;
                    state.structureId = st.GetInteriorForId();
                    SaveState.Add(state);
                }
            }

            // All objs on ground
            foreach (var item in ItemUtility.ItemsToUpdate)
            {
                OnGroundState ogs = new OnGroundState();
                ogs.objKey   = item.bbKey;
                ogs.region   = item.regionKey;
                ogs.team     = TeamType.Gusto;
                ogs.location = item.location;
                if (item is IInventoryItem)
                {
                    ogs.inventoryItem = true;
                    InventoryItem ii = (InventoryItem)item;
                    ogs.amountStacked = ii.amountStacked;
                }
                else
                {
                    ogs.inventoryItem = false;
                }
                if (item is IStorage)
                {
                    Storage storage = (Storage)item;
                    ogs.inventory = SerializeInventory(storage.inventory);
                }
                else if (item is IContainer)
                {
                    Container cont = (Container)item;
                    ogs.inventory = SerializeInventory(cont.drops);
                }

                SaveState.Add(ogs);
            }

            // Can do the weather state separately becasue it is not in the updateOrder
            WeatherSaveState wss = new WeatherSaveState();

            wss.currentMsOfDay        = WeatherState.currentMsOfDay;
            wss.currentLightIntensity = WeatherState.currentLightIntensity;
            wss.sunAngleX             = WeatherState.sunAngleX;
            wss.shadowTransparency    = WeatherState.shadowTransparency;
            wss.nDays            = WeatherState.totalDays;
            wss.weatherDuration  = WeatherState.weatherDuration;
            wss.msThroughWeather = WeatherState.msThroughWeather;
            wss.rainState        = WeatherState.rainState;
            wss.rainIntensity    = WeatherState.rainIntensity;
            wss.lightning        = WeatherState.lightning;
            SaveState.Add(wss);



            // serialize save to file system
            DataContractSerializer s = new DataContractSerializer(typeof(List <ISaveState>));

            using (FileStream fs = new FileStream(savePath + "GustoGame_" + gameName, FileMode.Create))
            {
                s.WriteObject(fs, SaveState);
            }
        }