Ejemplo n.º 1
0
    public static List <DetectedBuilding> DetectBuildings(Space space, BlueprintLibrary library)
    {
        List <BaseBlueprint> bPrints = library.GetAllBlueprints();

        bPrints     = FindPossibleBlueprints(bPrints, space.GetAvaiableMaterial());
        Tile[,] Map = space.Map;

        List <DetectedBuilding> possibleBuildings = new List <DetectedBuilding>();

        for (int x = 0; x < Map.GetLength(0); x++)
        {
            for (int z = 0; z < Map.GetLength(1); z++)
            {
                foreach (var item in bPrints)
                {
                    SimpleCords cord = new SimpleCords(x, z);
                    // rotate
                    for (int i = 0; i < 4; i++)
                    {
                        if (CheckBlueprint(Map, item, cord, i))
                        {
                            possibleBuildings.Add(new DetectedBuilding(item.Name, cord, i));
                        }
                    }
                }
            }
        }
        return(possibleBuildings);
    }
Ejemplo n.º 2
0
    void DoOutput()
    {
        foreach (var item in space.Buildings)
        {
            if ((item.Output.ConsumeToGo == 0 && item.Output.TimeToGo == 0) || (!item.Input.enabled && item.Output.TimeToGo == 0))
            {
                //Debug.Log("should do output");
                SimpleCords spawnlocation = item.CenterLocation.OffsetBy(item.Output.DeliveryLocation);
                string      materialName  = item.Output.MaterialName;
                Tile        t             = space.Map.SaveGet(spawnlocation.x, spawnlocation.z);
                if (t.occupation == TileOccupation.Empty)
                {
                    BaseMaterial mat = materials.GetMaterialByName(materialName);
                    space.SpawnMaterial(mat, spawnlocation);

                    if (item.Input.enabled)
                    {
                        item.Output.ConsumeToGo = item.Output.ConsumeAmount;
                        item.Input.ConsumeToGo  = item.Input.ConsumeAmount;
                        item.Output.TimeToGo    = -1;
                    }
                    else
                    {
                        item.Output.TimeToGo = item.Output.DeliverTimer;
                    }
                    item.Clock.SetTimer(item.Output.TimeToGo);
                }
                item.Clock.SetTimer(item.Output.TimeToGo);
            }
        }
        ReportDone();
    }
Ejemplo n.º 3
0
    public static Tile GetTraversabalTile(Tile tile, Direction dir)
    {
        SimpleCords OtherCord = tile.position.GetInDirection(dir, 1).GetAbove();

        for (int h = OtherCord.h; h >= 0; h--)
        {
            Tile tmp = GetTileWithCords(new SimpleCords(OtherCord.x, OtherCord.y, h));
            if (tmp != null && tmp.Empty == false)
            {
                if (tmp.Passable == true)
                {
                    return(tmp);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                Debug.LogError("We didnt find a tile");
            }
        }
        return(null);
    }
Ejemplo n.º 4
0
    void ShowPossibleDroplocations()
    {
        SimpleCords origin = originLocation;
        GameObject  GOo    = GameObject.Instantiate(ResourceLibrary.GetPrefabByName("prop_TileHighlightOrigin"));

        GOo.transform.position = origin;
        possiblePositionsGO    = new List <GameObject>();
        possiblePositions      = new List <SimpleCords>();
        possiblePositionsGO.Add(GOo);
        possiblePositions.Add(origin);

        //TODO: change it to whatever we want
        Offset[] miniOffsets = new Offset[]
        {
            new Offset(1, 0),
            new Offset(-1, 0),
            new Offset(0, 1),
            new Offset(0, -1),
        };

        foreach (var item in miniOffsets)
        {
            SimpleCords pos = origin;
            pos = pos.OffsetBy(item);
            Tile currCheck;
            while ((currCheck = space.Map.SaveGet(pos.x, pos.z)).occupation == TileOccupation.Empty)
            {
                GameObject tmp = GameObject.Instantiate(ResourceLibrary.GetPrefabByName("prop_TileHighlightGood"));
                tmp.transform.position = pos;
                possiblePositions.Add(pos);
                possiblePositionsGO.Add(tmp);
                pos = pos.OffsetBy(item);
            }
        }
    }
Ejemplo n.º 5
0
    private static CoverType CheckCover(Tile origin, Direction dir)
    {
        int coverValue = 0;

        if (origin.UnObstructed)
        {
            // cover provided by the origin itself
            int thisCover = (int)origin.TileObjects.CoverProvided(dir, true);


            // search for the highest Tile avaiable in that direction (max height 2)
            SimpleCords otherCords = origin.position.GetInDirection(dir, 1);
            int         otherCover = 0;
            for (int h = 2; h >= 0; h--)
            {
                Tile tmp = GetTileWithCords(new SimpleCords(otherCords.x, otherCords.y, otherCords.h + h));
                if (tmp != null)
                {
                    otherCover = (int)tmp.ProvidesCoverToTile(origin.position);
                    h          = -1;
                }
            }

            coverValue = Mathf.Max(thisCover, otherCover);
        }
        coverValue = Mathf.Min(coverValue, 2);
        return((CoverType)coverValue);
    }
Ejemplo n.º 6
0
 /// <summary>
 /// a tile needs its location for information, it automatically start empty
 /// </summary>
 /// <param name="position">position of the tile</param>
 public Tile(SimpleCords position)
 {
     this.position = position;
     Building      = null;
     Material      = null;
     occupation    = TileOccupation.Empty;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// remove a material
 /// </summary>
 /// <param name="t">the tile with the material on it</param>
 private void RemoveOccupation(Tile t)
 {
     Debug.Log("Called");
     if (t.occupation == TileOccupation.Material)
     {
         t.occupation = TileOccupation.Empty;
         space.Materials.Remove(t.Material);
         ObjectsToReturn.RemoveAll((x) => { return(x.Key == t.Material.GameObject); });
         Destroy(t.Material.GameObject);
         t.Material = null;
     }
     if (t.occupation == TileOccupation.Building)
     {
         BaseBuilding b = t.Building;
         Destroy(b.Clock.gameObject);
         foreach (var item in b.occupying)
         {
             SimpleCords removLoc = b.CenterLocation.OffsetBy(item);
             Tile        tile     = space.Map.SaveGet(removLoc.x, removLoc.z);
             if (tile.occupation == TileOccupation.Building)
             {
                 tile.Building   = null;
                 tile.occupation = TileOccupation.Empty;
             }
         }
         space.Buildings.Remove(t.Building);
         Destroy(b.GameObject);
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// basic init with position
 /// </summary>
 /// <param name="position">position of this Tile</param>
 public Tile(SimpleCords position) : this()
 {
     this.position = position;
     Passable      = true;
     UnObstructed  = true;
     Empty         = false;
 }
Ejemplo n.º 9
0
    /// <summary>
    /// use this with unplaced Objects
    /// </summary>
    /// <param name="material">the material</param>
    /// <param name="location">position of placement</param>
    public void SpawnMaterial(BaseMaterial material, SimpleCords location)
    {
        Map[location.x, location.z].Material   = material;
        Map[location.x, location.z].occupation = TileOccupation.Material;

        material.Place(location);
        Materials.Add(material);
    }
Ejemplo n.º 10
0
    public GameObject GetGameObjectAtOfType(SimpleCords sc, Type t)
    {
        ChangeTool("Clockwise");
        GameObject go   = Instantiate(EmptySprite);
        Sprite     s    = null;
        string     name = "";

        switch (t)
        {
        case Type.Concrete:
            s    = Instantiate(Concrete);
            name = "Concrete";
            break;

        case Type.ConcreteCracked:
            break;

        case Type.Consumer:
            go   = Instantiate(House);
            name = "Consumer";
            go.transform.position = new Vector2(sc.X, sc.Y);
            go.name = name + "(" + sc.X + "," + sc.Y + ")";
            return(go);

        case Type.Pump:
            go   = Instantiate(Pump);
            name = "Pump";
            go.transform.position = new Vector2(sc.X, sc.Y);
            go.name = name + "(" + sc.X + "," + sc.Y + ")";
            return(go);

        case Type.Dirt:
            s    = Instantiate(Dirt);
            name = "Dirt";
            break;

        case Type.Gras:
            s    = Instantiate(Gras);
            name = "Gras";
            break;

        case Type.Sapling:
            break;

        case Type.Empty:
            break;

        default:
            break;
        }
        go.GetComponent <SpriteRenderer>().sprite = s;
        go.transform.position = new Vector2(sc.X, sc.Y);
        go.name = name + "(" + sc.X + "," + sc.Y + ")";
        return(go);
    }
Ejemplo n.º 11
0
 public static Tile GetTileWithCords(SimpleCords cords)
 {
     try
     {
         return(map[cords.x, cords.y, cords.h]);
     }
     catch (System.IndexOutOfRangeException)
     {
         return(null);
     }
 }
Ejemplo n.º 12
0
 public void Place(SimpleCords atLocation)
 {
     if (usable)
     {
         GameObject obj = Object.Instantiate(ResourceLibrary.GetPrefabByName(VisualName));
         obj.transform.position = new Vector3(atLocation.x, atLocation.y + 0.5f, atLocation.z);
         GameObject             = obj;
     }
     else
     {
         throw new System.Exception("Used Unusable Material!");
     }
 }
Ejemplo n.º 13
0
    private void BuildBuilding(DetectedBuilding detectedBuilding)
    {
        BaseBuilding b = buildings.GetBuildingByName(detectedBuilding.BuildingName);

        foreach (var item in b.occupying)
        {
            SimpleCords cords = detectedBuilding.Location.OffsetBy(item.Rotate(detectedBuilding.Orientation));
            Debug.Log("occupying: " + cords);
            RemoveOccupation(space.Map.SaveGet(cords.x, cords.z));
        }
        space.SpawnBuilding(b, detectedBuilding.Location, detectedBuilding.Orientation);

        AdvanceToProcessing();
    }
Ejemplo n.º 14
0
    public static bool CheckBlueprint(Tile[,] Map, BaseBlueprint blueprint, SimpleCords location, int rotationToUse = 0)
    {
        int mapWidth  = Map.GetLength(0);
        int mapHeight = Map.GetLength(1);

        if (location.x + blueprint.NegWidth < 0)
        {
            return(false);
        }
        if (location.y + blueprint.NegHeight < 0)
        {
            return(false);
        }
        if (location.x + blueprint.PosWidth > mapWidth)
        {
            return(false);
        }
        if (location.y + blueprint.PosHeight > mapHeight)
        {
            return(false);
        }
        bool exist = true;

        List <MaterialOffset> offsets = blueprint.MaterialRequirements.RotateBy90Deg(rotationToUse);

        foreach (var item in offsets)
        {
            // skip over logic
            if (!exist)
            {
                continue;
            }
            // do we even have to check if there the materials match?
            if (Map.SaveGet(item.Offset.x + location.x, item.Offset.y + location.z).occupation != TileOccupation.Material)
            {
                exist = false;
            }
            else
            {
                if (Map.SaveGet(item.Offset.x + location.x, item.Offset.y + location.z).Material.Name != item.MaterialName)
                {
                    exist = false;
                }
            }
        }
        return(exist);
    }
Ejemplo n.º 15
0
    /// <summary>
    /// use this with unplaced Objects
    /// </summary>
    /// <param name="building">the building</param>
    /// <param name="location">position of placement</param>
    public void SpawnBuilding(BaseBuilding building, SimpleCords location, int orientation)
    {
        Map[location.x, location.z].Building   = building;
        Map[location.x, location.z].occupation = TileOccupation.Building;

        foreach (var item in building.occupying)
        {
            Debug.Log("Spawn Building with orientation: " + orientation);
            SimpleCords c = location.OffsetBy(item.Rotate(orientation));
            Map[c.x, c.z].Building   = building;
            Map[c.x, c.z].occupation = TileOccupation.Building;
        }

        building.CenterLocation = location;
        building.PlaceWithOrientation(orientation, location);
        Buildings.Add(building);
    }
Ejemplo n.º 16
0
    private void MoveMaterial(SimpleCords from, SimpleCords to, BaseMaterial m)
    {
        if (from.Equals(to))
        {
            return;
        }

        Tile f = space.Map.SaveGet(from.x, from.z);
        Tile t = space.Map.SaveGet(to.x, to.z);

        f.occupation = TileOccupation.Empty;
        f.Material   = null;
        t.occupation = TileOccupation.Material;
        t.Material   = m;
        m.position   = t.position;
        AdvanceToProcessing();
    }
Ejemplo n.º 17
0
    /// <summary>
    /// This methode calculates how much cover this tile provides to another Tile
    /// </summary>
    /// <returns></returns>
    public CoverType ProvidesCoverToTile(SimpleCords otherTileLocation)
    {
        int coverValue = 0;

        Direction thisDir = position.GetDirectionTo(otherTileLocation);

        int heightDifference = position.h - otherTileLocation.h;

        CoverType objectcoverToOtherTile = TileObjects.CoverProvided(thisDir, true);

        coverValue = heightDifference + (int)objectcoverToOtherTile;
        coverValue = Mathf.Min(coverValue, 2);

        if (coverValue <= 0)
        {
            return(CoverType.None);
        }
        return((CoverType)coverValue);
    }
Ejemplo n.º 18
0
 void DoInput()
 {
     foreach (var item in space.Buildings)
     {
         if (item.Input.enabled)
         {
             SimpleCords inputLocation = item.CenterLocation.OffsetBy(item.Input.InputLocation);
             if (item.Input.ConsumeToGo > 0)
             {
                 Tile t = space.Map.SaveGet(inputLocation.x, inputLocation.z);
                 if (t.occupation == TileOccupation.Material && t.Material.Name == item.Input.MaterialName)
                 {
                     item.Input.ConsumeToGo--;
                     item.Output.ConsumeToGo--;
                     RemoveOccupation(t);
                 }
             }
         }
     }
     ReportDone();
 }
Ejemplo n.º 19
0
    public void PlaceWithOrientation(int rotation, SimpleCords atLocation)
    {
        if (usable)
        {
            Orientatation = rotation;

            for (int i = 0; i < occupying.Length; i++)
            {
                occupying[i] = occupying[i].Rotate(Orientatation);
            }

            GameObject obj = Object.Instantiate(ResourceLibrary.GetPrefabByName(VisualName));
            obj.transform.position = atLocation;
            obj.transform.rotation = Quaternion.Euler(0, 90 * (rotation + 1), 0);
            GameObject             = obj;
            GameObject t = Object.Instantiate(ResourceLibrary.GetPrefabByName("prop_Timer"));
            t.transform.position = atLocation;
            Clock = t.GetComponentInChildren <lookAtCamera>();
            Timer = t;

            Input.InputLocation     = Input.InputLocation.Rotate(Orientatation);
            Output.DeliveryLocation = Output.DeliveryLocation.Rotate(Orientatation);

            if (Input.enabled)
            {
                Clock.SetTimer(-1);
            }
            else
            {
                Clock.SetTimer(Output.DeliverTimer);
            }
            // TODO: Place Object with everything
        }
        else
        {
            throw new System.Exception("Used Unusable Building!");
        }
    }
Ejemplo n.º 20
0
    /// <summary>
    /// this methode returns the direction towards a different <see cref="SimpleCords"/>
    /// </summary>
    /// <param name="other">The other cord</param>
    /// <returns>Direction to that other <see cref="SimpleCords"/></returns>
    public Direction GetDirectionTo(SimpleCords other)
    {
        SimpleCords vector = other - this;

        float angle = Mathf.Atan2(vector.x, vector.z);

        if (angle < Mathf.PI / 4 || angle > Mathf.PI / 4 * 7)
        {
            return(Direction.East);
        }
        if (angle > Mathf.PI / 4 && angle < Mathf.PI / 4 * 3)
        {
            return(Direction.North);
        }
        if (angle > Mathf.PI / 4 * 3 && angle < Mathf.PI / 4 * 5)
        {
            return(Direction.West);
        }
        if (angle > Mathf.PI / 4 * 5 && angle < Mathf.PI / 4 * 7)
        {
            return(Direction.South);
        }
        return(Direction.North);
    }
Ejemplo n.º 21
0
 public DetectedBuilding(string buildingName, SimpleCords location, int orientation)
 {
     BuildingName = buildingName;
     Location     = location;
     Orientation  = orientation;
 }
Ejemplo n.º 22
0
 public SimpleCords(SimpleCords cords)
 {
     this.x = cords.x;
     this.z = cords.z;
     this.y = cords.y;
 }
Ejemplo n.º 23
0
 public SimpleCords(SimpleCords cords)
 {
     this.x = cords.x;
     this.y = cords.y;
     this.h = cords.h;
 }
Ejemplo n.º 24
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.R))
        {
            restart += Time.deltaTime;
            if (restart > restartTime)
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            }
        }
        else
        {
            restart = 0f;
        }

        if (space.GetAvaiableMaterial().ContainsKey("Amazing Product") || (Input.GetKey(KeyCode.B) && Input.GetKey(KeyCode.M)))
        {
            winThere = true;
        }

        if (winThere)
        {
            winMet += Time.deltaTime;
        }

        if (winMet >= winDelay)
        {
            WinScreen.SetActive(true);
        }

        MoveAllObjectsBack();

        //TODO delete this
        if (!spawned && Time.time > 1)
        {
            Debug.Log("Something should have happend");

            //space.SpawnMaterial(materials.GetMaterialByName("Dirt"), new SimpleCords(1, 1));
            //space.SpawnMaterial(materials.GetMaterialByName("Dirt"), new SimpleCords(4, 1));
            //space.SpawnMaterial(materials.GetMaterialByName("Dirt"), new SimpleCords(1, 3));

            //space.SpawnMaterial(materials.GetMaterialByName("Clay"), new SimpleCords(0, 2));
            //space.SpawnMaterial(materials.GetMaterialByName("Clay"), new SimpleCords(0, 3));

            //space.SpawnMaterial(materials.GetMaterialByName("Clay"), new SimpleCords(2, 2));
            //space.SpawnMaterial(materials.GetMaterialByName("Clay"), new SimpleCords(2, 3));

            //space.SpawnMaterial(materials.GetMaterialByName("Clay"), new SimpleCords(4, 2));
            //space.SpawnMaterial(materials.GetMaterialByName("Clay"), new SimpleCords(4, 3));

            space.SpawnBuilding(buildings.GetBuildingByName("Quarry"), new SimpleCords(3, 3), 0);
            space.SpawnMaterial(materials.GetMaterialByName("Stone"), new SimpleCords(0, 0));

            //space.SpawnMaterial(materials.GetMaterialByName("Dirt"),new SimpleCords(3,2));
            AdvanceToProcessing();
            spawned = true;
        }


        RaycastHit hit;
        var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        // set the hitmask to be layer 10 (floor) and 11 (Hoverable)

        // flow control
        switch (State)
        {
        case GameState.Menu:
            // check menu items for clicks with raycasts

            //TODO: make a menu

            break;

        case GameState.PauseMenu:


            break;

        case GameState.Idle:
            // check everything for clicks with raycasts
            // check for hover
            // if hover start displaying Information (i think just the name for now)
            // check for legal moves on drag and so on
            if (space.GetAvaiableMaterial().Count == 0 && space.IsBuildingDelivering())
            {
                State = GameState.Skipping;
                // skipp ahead
            }
            else
            {
                #region Idle Mouse things
                // normal user input proceeding
                if (Input.GetKey(KeyCode.Mouse0) || Input.GetKeyDown(KeyCode.Mouse0))
                {
                    // stop hovering because of click

                    if (isHovering)
                    {
                        toolTip.HideToolTip();
                        isHovering = false;
                        hoverTime  = 0f;
                    }

                    switch (activeTool)
                    {
                    case Tool.Shovel:
                        int m = 1 << 10;
                        //Debug.Log("HELLO?");
                        RaycastHit hit1;
                        if (Physics.Raycast(ray, out hit1, 100, m))
                        {
                            Vector3     hitLoc   = hit1.point;
                            SimpleCords location = new SimpleCords((int)Mathf.Round(hitLoc.x), (int)0, (int)Mathf.Round(hitLoc.z));
                            Tile        t        = space.Map.SaveGet(location.x, location.z);
                            //Debug.Log("Shovel attack"+hitLoc);
                            if (t.occupation == TileOccupation.Empty)
                            {
                                space.SpawnMaterial(materials.GetMaterialByName("Dirt"), t.position);
                            }
                            activeTool = Tool.Move;
                            txt.text   = "Move";
                            AdvanceToProcessing();
                        }
                        break;

                    case Tool.Move:
                        if (isHolding)
                        {
                            // move the held Object around until we drop it
                            // get location
                            int mask = 1 << 10;
                            if (Physics.Raycast(ray, out hit, 100, mask))
                            {
                                //Debug.Log("hit something and i am starting to calculate");
                                Vector3     hitLoc   = hit.transform.position;
                                SimpleCords location = new SimpleCords((int)Mathf.Round(hitLoc.x), (int)originLocation.y, (int)Mathf.Round(hitLoc.z));

                                bool contains = false;
                                for (int i = 0; i < possiblePositions.Count; i++)
                                {
                                    if (possiblePositions[i].Equals(location))
                                    {
                                        holdPosition = location;
                                    }
                                }
                            }
                            else
                            {
                                // we dont care that can happen when going to far
                                //Debug.Log("spam");
                            }
                            ObjectsToReturn.RemoveAll((x) => x.Key == heldMaterial.GameObject);
                            heldMaterial.GameObject.transform.position = Vector3.Lerp(heldMaterial.GameObject.transform.position, new Vector3(0f, 1.5f, 0f) + (Vector3)holdPosition, 8 * Time.deltaTime);
                        }
                        else
                        {
                            // get gameobject we are pointing at
                            int hitmask = 1 << 11;
                            // if we dont hit anything we dont want to grab
                            // lets work on changing that
                            if (Physics.Raycast(ray, out hit, 100, hitmask))
                            {
                                Vector3     hitLoc   = hit.transform.position;
                                SimpleCords location = new SimpleCords((int)Mathf.Round(hitLoc.x), (int)Mathf.Round(hitLoc.y), (int)Mathf.Round(hitLoc.z));
                                Tile        t        = space.Map.SaveGet(location.x, location.z);
                                //
                                if (t.occupation == TileOccupation.Material)
                                {
                                    holdTime       += Time.deltaTime;
                                    holdingMaterial = t.Material;
                                    if (holdTime > requiredHoldTime)
                                    {
                                        // we have to switch a lot around
                                        isHolding      = true;
                                        moveState      = MoveState.Raise;
                                        originLocation = location;
                                        heldMaterial   = t.Material;
                                        holdPosition   = location;
                                        ShowPossibleDroplocations();
                                    }
                                }
                            }
                            else
                            {
                                // we dont point at anything so we just reset some numbers
                                holdTime = 0f;
                            }
                        }
                        break;

                    case Tool.Delete:

                        int ma = 1 << 11;
                        if (Physics.Raycast(ray, out hit, 100, ma))
                        {
                            //Debug.Log("hit something and i am starting to calculate");
                            Vector3     hitLoc   = hit.transform.position;
                            SimpleCords location = new SimpleCords((int)Mathf.Round(hitLoc.x), 0, (int)Mathf.Round(hitLoc.z));
                            Tile        t        = space.Map.SaveGet(location.x, location.z);

                            if (t.occupation == TileOccupation.Building)
                            {
                                RemoveOccupation(t);
                                activeTool = Tool.Move;
                                txt.text   = "Move";
                                AdvanceToProcessing();
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    // if we were holding something lets put it back
                    DropMaterial();


                    // hover calculations
                    int hitmask = 1 << 11 | 1 << 10;
                    if (Physics.Raycast(ray, out hit, 100, hitmask))
                    {
                        Vector3     hitLoc   = hit.transform.position;
                        SimpleCords location = new SimpleCords((int)Mathf.Round(hitLoc.x), (int)Mathf.Round(hitLoc.y), (int)Mathf.Round(hitLoc.z));
                        Tile        t        = space.Map.SaveGet(location.x, location.z);
                        //Debug.Log(t.occupation);
                        if (isHovering)
                        {
                            if (t.occupation == TileOccupation.Material && isHoveringMaterial && t.Material == hoverMaterial)
                            {
                                // still hovering over the same Material
                            }
                            else
                            {
                                if (t.occupation == TileOccupation.Building && isHoveringMaterial && t.Building == hoverBuilding)
                                {
                                    // still hovering over the same Building
                                }
                                else
                                {
                                    // we are not hovering over the same anymore
                                    // hide tooltip and so on
                                    toolTip.HideToolTip();
                                    isHovering = false;
                                    hoverTime  = 0f;
                                    switch (t.occupation)
                                    {
                                    case TileOccupation.Empty:
                                        break;

                                    case TileOccupation.Material:
                                        // new material
                                        isHoveringMaterial = true;
                                        hoverMaterial      = t.Material;
                                        break;

                                    case TileOccupation.Building:
                                        // new building
                                        isHoveringMaterial = false;
                                        hoverBuilding      = t.Building;
                                        break;

                                    case TileOccupation.Error:
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (t.occupation == TileOccupation.Material && isHoveringMaterial && t.Material == hoverMaterial)
                            {
                                hoverTime += Time.deltaTime;
                                // still hovering over the same Material
                                if (hoverTime >= requiredHoverTime)
                                {
                                    isHovering = true;
                                    toolTip.ShowToolTipMaterial(t.Material);
                                }
                            }
                            else
                            {
                                if (t.occupation == TileOccupation.Building && isHoveringMaterial && t.Building == hoverBuilding)
                                {
                                    hoverTime += Time.deltaTime;
                                    // still hovering over the same Building
                                    if (hoverTime >= requiredHoverTime)
                                    {
                                        isHovering = true;
                                        toolTip.ShowToolTipBuilding(t.Building);
                                    }
                                }
                                else
                                {
                                    isHovering = false;
                                    hoverTime  = 0f;
                                    switch (t.occupation)
                                    {
                                    case TileOccupation.Material:
                                        // new material
                                        isHoveringMaterial = true;
                                        hoverMaterial      = t.Material;
                                        break;

                                    case TileOccupation.Building:
                                        // new building
                                        isHoveringMaterial = false;
                                        hoverBuilding      = t.Building;
                                        break;

                                    default:
                                        hoverBuilding = null;
                                        hoverMaterial = null;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (isHovering)
                        {
                            toolTip.HideToolTip();
                            isHovering = false;
                            hoverTime  = 0f;
                        }
                    }
                }



                #endregion
            }



            break;

        case GameState.Processing:
            // work through the ProcessingQueue
            // every process has to finish by calling the "ReportDone" Method
            if (ProcessQueue.Count == 0 && ProcessCompleted)
            {
                State = GameState.Idle;
                Debug.Log("Moving to Idle");
            }
            else
            {
                if (ProcessCompleted)
                {
                    //Debug.Log("Process Complete and redoing");
                    // execute the first delegate (this looks really funny :D)
                    ProcessCompleted = false;
                    ProcessQueue.Dequeue().Invoke();

                    //Debug.Log("Invoked and waiting");
                }
                else
                {
                }
            }
            break;

        case GameState.Skipping:
            // temporary state that is just for skipping the players input phase
            // because there is nothing to do
            AdvanceToProcessing();

            break;

        default:
            break;
        }
    }
Ejemplo n.º 25
0
 public Tile(SimpleCords pos)
 {
     position = pos;
 }