Ejemplo n.º 1
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Debug.LogError(gameObject + " was a second Instance! and was destroyed for it!");
            Destroy(gameObject);
        }

        if (GridObjects.Length != Enum.GetNames(typeof(GridObjectID)).Length)
        {
            Debug.LogError("Il database GridObjects non contiene il giusto numero di Classi. Procedere a Implementarli!");
        }

        for (int i = 0; i < GridObjects.Length; i++)
        {
            GridObjectData DATA = GridObjects[i];

            DATA.ID   = (GridObjectID)i;
            DATA.Name = DATA.ID.ToString();

            DATA.Size.x = DATA.Size.x == 0 ? 1 : DATA.Size.x;
            DATA.Size.y = DATA.Size.y == 0 ? 1 : DATA.Size.y;


            GridObjects[i] = DATA;
        }
    }
Ejemplo n.º 2
0
 public GridObject(Transform gameObject, GridObjectData data, Vector3Int gridLocation, EDirection direction)
 {
     ObjectData         = data;
     Object             = gameObject;
     ObjectGridLocation = gridLocation;
     ObjectDirection    = direction;
 }
Ejemplo n.º 3
0
    public bool IsObjectValid(GridObjectData objectData, Vector3Int tileLocation, EDirection direction)
    {
        // Get the tile dimensions of the object
        Vector3Int dimensions = objectData.GetDimensions(direction);
        int        width      = dimensions.x;
        int        depth      = dimensions.y;
        int        length     = dimensions.z;

        // The offset to the origin of the object in tiles space
        Vector3Int globalOffset = tileLocation + objectData.GetTilesOffset(direction);

        // Check if object is in range of the grid
        if (globalOffset.x < 0 ||
            globalOffset.y < 0 ||
            globalOffset.z < 0 ||
            globalOffset.x + width - 1 >= Width ||
            globalOffset.y + depth - 1 >= Depth ||
            globalOffset.z + length - 1 >= Length)
        {
            return(false);
        }

        for (int y = 0; y < depth; ++y)
        {
            for (int x = 0; x < width; ++x)
            {
                for (int z = 0; z < length; ++z)
                {
                    // Only do checks if the current tile is solid
                    if (objectData.GetIsSolid(x, y, z, direction))
                    {
                        // Get the location of the tile on the grid space
                        Vector3Int globalTileLoc = new Vector3Int(x, y, z) + globalOffset;

                        // If the tile is not free
                        if (Tiles[globalTileLoc.x, globalTileLoc.y, globalTileLoc.z] != null)
                        {
                            // Intersection found
                            return(false);
                        }
                        // Make sure that if the object needs to be supported the tile has something to stand on
                        else if (objectData.MustBeSupported &&
                                 globalTileLoc.y > 0 &&                                                                   // The ground is solid so no need to check
                                 (y == 0 || !objectData.GetIsSolid(x, y - 1, z, direction)) &&                            // Only check tiles with space underneath it
                                 (Tiles[globalTileLoc.x, globalTileLoc.y - 1, globalTileLoc.z] == null ||                 // Check if the block under is null
                                  !Tiles[globalTileLoc.x, globalTileLoc.y - 1, globalTileLoc.z].ObjectData.CanBeBuiltOn)) // Block under is not null but is unstable
                        {
                            // No support found
                            return(false);
                        }
                    }
                }
            }
        }

        return(true);
    }
Ejemplo n.º 4
0
    public virtual void Deserialize(string message)
    {
        GridObjectData deserialized = JsonConvert.DeserializeObject <GridObjectData>(message);

        Direction = deserialized.Direction;
        X         = deserialized.X;
        Y         = deserialized.Y;
        Z         = deserialized.Z;
        Owner     = deserialized.Owner;
    }
Ejemplo n.º 5
0
    // Gets the tile location of the to be placed tile
    public bool GetMousePlaceTileLocation(GridObjectData data, EDirection rotation, Camera camera, Vector2 screenLocation, float range, out Vector3Int tileLocation)
    {
        // Define raycast
        RaycastHit hit;
        Ray        ray = camera.ScreenPointToRay(screenLocation);

        // Raycast out 100 units on the grids collision layer
        if (Physics.Raycast(ray, out hit, range, CollisionLayer))
        {
            // The to be pushed out locations
            Vector3 newLoc;

            // We know that all colliders are box colliders
            Vector3 colliderLocation = ((BoxCollider)hit.collider).center;

            // Check if the collider is the floor collider
            if (colliderLocation.y > transform.position.y)
            {
                // Push the location away from the tile in the greatest direction
                Vector3 delta     = hit.point - colliderLocation;
                Vector3 deltaAbs  = new Vector3(Mathf.Abs(delta.x), Mathf.Abs(delta.y), Mathf.Abs(delta.z));
                Vector3 direction = new Vector3(
                    Convert.ToInt32(deltaAbs.x > deltaAbs.y && deltaAbs.x > deltaAbs.z) * Mathf.Sign(delta.x),
                    Convert.ToInt32(deltaAbs.y > deltaAbs.x && deltaAbs.y > deltaAbs.z) * Mathf.Sign(delta.y),
                    Convert.ToInt32(deltaAbs.z > deltaAbs.y && deltaAbs.z > deltaAbs.x) * Mathf.Sign(delta.z));

                // Push the tile far enough away that it fits
                Vector3Int dimensions = data.GetDimensions(rotation);
                Vector3Int offset     = data.GetTilesOffset(rotation);
                Vector3Int diff       = (direction.x + direction.y + direction.z > 0.0f ? -offset + Vector3Int.one : dimensions + offset);

                // Bring it all together xd
                newLoc = colliderLocation + Vector3.Scale(direction, new Vector3(diff.x, diff.y, diff.z)) * TileSize;
            }
            else
            {
                // Bring location out of the ground
                newLoc = new Vector3(hit.point.x, transform.position.y + TileSize * 0.5f, hit.point.z);
            }

            // Convert to tile coordinates and make sure it's within bounds
            if (WorldToTile(newLoc, out tileLocation))
            {
                // Tile location is already set in the above if statement ^
                return(true);
            }
        }

        // Failed somewhere
        tileLocation = new Vector3Int();
        return(false);
    }
Ejemplo n.º 6
0
    public void GenerateObject(GridSystem gSystem, Vector2Int pos, GridObjectData data, bool ignoreCollide = false, bool shouldBeOnCooldown = false)
    {
        GridInventory inventory = gSystem.Inventory;
        Quaternion    sampleOverrideRotation = Quaternion.identity;
        Vector3       worldPos = gSystem.GridToWorld(pos);
        GameObject    obj      = Instantiate(data.Prefab, worldPos, sampleOverrideRotation);

        GridObject gObj = obj.GetComponent <GridObject>();

        gObj.InitializeFromDataFile(data, shouldBeOnCooldown);

        inventory.AddObject(obj.GetComponent <GridObject>(), pos, ignoreCollide);
    }
Ejemplo n.º 7
0
 public override void LoadObjectData(GridObjectData gridObjectData)
 {
     priceText.text = price.GetPriceText();
     if (amountBought > 0)
     {
         OpenBoughtPanel();
         buyButton.interactable = false;
         AbilityManager.instance.UnlockAbility(abilityId);
     }
     else
     {
         boughtPanel.SetActive(false);
     }
 }
Ejemplo n.º 8
0
    public void SetObjectToBuild(GridObjectData DATA)
    {
        if (DATA == null)
        {
            return;
        }

        GridObjectToBuild = DATA;

        if (OnGridObjectToBuildChanged != null)
        {
            OnGridObjectToBuildChanged();
        }
    }
Ejemplo n.º 9
0
    public void SetObjectToBuild(GridObjectID ID)
    {
        GridObjectData DATA = IDManager.Instance.GetData(ID);

        if (DATA == null)
        {
            return;
        }

        GridObjectToBuild = DATA;

        if (OnGridObjectToBuildChanged != null)
        {
            OnGridObjectToBuildChanged();
        }
    }
Ejemplo n.º 10
0
    public bool GenerateObject(Vector3 objWorldPosition, GridObjectData data, bool ignoreCollide = false)
    {
        GridSystem gSysteme;
        Vector2Int gPos;

        if (GridManager.Instance.GetGridCoords(objWorldPosition, out gSysteme, out gPos))
        {
            Vector3    worldGridCellPos       = gSysteme.GridToWorld(gPos);
            Quaternion sampleOverrideRotation = Quaternion.identity;
            GameObject obj = Instantiate(data.Prefab, worldGridCellPos, sampleOverrideRotation);

            GridObject gObj = obj.GetComponent <GridObject>();
            gObj.InitializeFromDataFile(data);

            // TODO: Check return value when using this
            return(gSysteme.Inventory.AddObject(obj.GetComponent <GridObject>(), gPos, ignoreCollide));
        }
        return(false);
    }
    public override void LoadObjectData(GridObjectData gridObjectData)
    {
        StudioUpgradeGridObjectData data = (StudioUpgradeGridObjectData)gridObjectData;

        upgradeImage.sprite     = data.UpgradeImage;
        upgradeTitle.text       = data.UpgradeTitle;
        upgradeDescription.text = data.UpgradeDescription;
        price                = data.Price;
        priceText.text       = price.GetPriceText();
        upgrade              = data.upgrade;
        upgradeGainText.text = UpgradeStringMaker.GetUpgradeString(data.upgrade.upgradeType, data.upgrade.upgradeValue);
        if (amountBought > 0)
        {
            OpenBoughtPanel();
            buyButton.interactable = false;
        }
        else
        {
            boughtPanel.SetActive(false);
        }
    }
Ejemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        // Retrieve the building from the radial parent
        CurrentObject = RadialParent.SelectedSegment;
        CanBuild      = (!RadialParent.IsVisible && RadialParent.IsEnabled);

        if (CanBuild && CurrentObject != "")
        {
            if (PlaceholderData.Cost == 0)
            {
                PlaceholderData = Grid3D.GetObjectData(CurrentObject).Value;
            }

            CheckForRotation();
            CheckForPlace();
            CheckForDestroy();
        }
        else if (PlaceholderObject != null)
        {
            Destroy(PlaceholderObject.gameObject);
        }
    }
Ejemplo n.º 13
0
    public void InitializeFromDataFile(GridObjectData data, bool shouldBeOnCooldown = false)
    {
        Data                = data;
        CoordinatesUsed     = data.CoordinatesUsed;
        TimeToDestroy       = data.TimeToDestroy;
        TimeToRespawn       = data.TimeToRespawn;
        gameObject.name     = data.name;
        transform.position -= _offset;

        _onSound  = data.TakeOnSound;
        _offSound = data.TakeOffSound;

        if (shouldBeOnCooldown)
        {
            LaunchSpawnCooldownFeedback();
            IsDragable = false;
        }
        else
        {
            IsDragable = true;
        }
    }
Ejemplo n.º 14
0
    private void UpdatePlaceholder(Grid3D grid, Vector3Int tileLocation)
    {
        // Update the placeholder if the object is changed
        if (PlaceholderName != CurrentObject && PlaceholderObject != null)
        {
            Destroy(PlaceholderObject.gameObject);
        }

        // Create a new placeholder object if it's null
        if (PlaceholderObject == null && CurrentObject != "")
        {
            PlaceholderName = CurrentObject;
            PlaceholderData = Grid3D.GetObjectData(CurrentObject).Value;

            // Generate a copy of the object
            PlaceholderObject          = Instantiate(Grid3D.GetObjectData(CurrentObject).Key);
            PlaceholderObject.rotation = Quaternion.AngleAxis((int)PlaceholderDirection * 90, Vector3.up);
            PlaceholderObject.name     = CurrentObject + " (Placeholder)";
            PlaceholderObject.parent   = transform;

            // Make transparent
            UpdateAllMaterials(PlaceholderObject.gameObject, PlaceholderMaterial);
            CullUnnecessaryComponents(PlaceholderObject.gameObject);
        }

        bool  isValid = grid.IsObjectValid(PlaceholderData, tileLocation, PlaceholderDirection);
        Color col     = isValid ? Color.green : Color.red;

        PlaceholderMaterial.color = new Color(col.r, col.g, col.b, 0.5f);

        // Update location
        Vector3 worldLocation = new Vector3();

        grid.TileToWorld(tileLocation, out worldLocation);
        PlaceholderObject.transform.position = worldLocation;

        // Update visual
        PlaceholderObject.gameObject.SetActive(true);
    }
Ejemplo n.º 15
0
    public override void LoadObjectData(GridObjectData gridObjectData)
    {
        data = (CrewGridObjectData)gridObjectData;
        upgradeImage.sprite     = data.UpgradeImage;
        upgradeTitle.text       = data.UpgradeTitle;
        upgradeDescription.text = data.UpgradeDescription;
        price = data.Price;
        currentPrice.currencyType = price.currencyType;
        SetPrice();
        statsToShow = data.StatsToShow;
        if (statsToShow)
        {
            statsText.gameObject.SetActive(true);
            statsText.text = StatsManager.instance.RequestStatsString(data.statsQuery);
        }
        else
        {
            statsText.gameObject.SetActive(false);
        }

        incrementalUpgrade = data.incrementalUpgrade;
    }
Ejemplo n.º 16
0
        public static GridObjectData CreateBattleSceneGridObjData(GridObject gridObject)
        {
            var ret = new GridObjectData();

            ret.obj.row   = gridObject.GridRef.PosRow;
            ret.obj.col   = gridObject.GridRef.PosCol;
            ret.highland  = gridObject.Highland;
            ret.obj.id    = gridObject.ID;
            ret.direction = gridObject.Direction;
            ret.obstacle  = gridObject.Obstacle;
            ret.stagnate  = gridObject.Stagnate;
            bool actable = ret.actable = gridObject is ActableGridObject;

            if (actable)
            {
                var actableObject = (ActableGridObject)gridObject;
                ret.actableObjData.actionPoint    = actableObject.ActionPoint;
                ret.actableObjData.actionPointMax = actableObject.ActionPointMax;
                ret.actableObjData.movable        = actableObject.Movable;
                ret.actableObjData.movePoint      = actableObject.MovePoint;
            }
            return(ret);
        }
Ejemplo n.º 17
0
    public bool SpawnScrapInRandomZone(GridObjectData data, Vector3 epicenter, float Range)
    {
        int tries = 10;

        while (tries >= 0)
        {
            --tries;
            Vector2    randCircle = Random.insideUnitCircle * Range;
            Vector3    position   = epicenter + new Vector3(randCircle.x, randCircle.y);
            GridSystem grid;
            Vector2Int gCoords;
            if (GetGridCoords(position, out grid, out gCoords))
            {
                if (grid.Inventory.Type == GridInventory.GridType.WorkBench)
                {
                    if (ObjectFactory.Instance.GenerateObject(position, data))
                    {
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
 public override void LoadObjectData(GridObjectData gridObjectData)
 {
 }
Ejemplo n.º 19
0
    public bool ApplyRecipe(GridObject dragged, GridObject target)
    {
        Recipe validRecipe = GetRecipeWithInputs(dragged, target);

        if (validRecipe == null)
        {
            return(false);
        }

        if (dragged.IsInCrafting || target.IsInCrafting)
        {
            return(false);
        }

        foreach (RecipeOutput output in validRecipe.Outputs)
        {
            GridObjectData targetInput = validRecipe.Inputs[output.InputObjectIndex].Object;

            GridObject inputObject   = null;
            Vector3    spawnPosition = Vector3.zero;
            if (output.InputObjectIndex == 0)
            {
                //inputObject = validRecipe.Inputs[0].Object;
                inputObject   = dragged;
                spawnPosition = dragged.initialDragPosition;
            }
            else if (output.InputObjectIndex == 1)
            {
                //inputObject = validRecipe.Inputs[1].Object;
                inputObject   = target;
                spawnPosition = target.transform.position;
            }

            if (inputObject == null)
            {
                Debug.LogError("Error in object index configuration for output (" + output.InputObjectIndex + ")", validRecipe);
                return(false);
            }

            // TODO add relative position
            //ObjectFactory.Instance.GenerateObject(inputObject.initialDragPosition, output.Object, true);
            ObjectFactory.Instance.GenerateObject(spawnPosition, output.Object, true);

            if (validRecipe.Sound.Clip != null)
            {
                MusicManager.Instance.PlaySound(validRecipe.Sound);
            }

            if (validRecipe.Accident != null && UnityEngine.Random.Range(0f, 1f) < validRecipe.AccidentPropability)
            {
                GridManager.Instance.SpawnScrapInRandomZone(validRecipe.Accident, target.transform.position, 4);
            }
        }

        int  index         = 0;
        bool placedBackObj = false;

        foreach (RecipeInput input in validRecipe.Inputs)
        {
            GridObject gObj = null;
            if (index == 0)
            {
                gObj = dragged;
            }
            else if (index == 1)
            {
                gObj = target;
            }
            else
            {
                Debug.LogWarning("Trying to assign an object with invalid index in recipe (" + index + ")");
            }

            if (input.Behavior == RecipeInput.CraftBehavior.Destroy)
            {
                GridSystem grid;
                Vector2Int gCoords;
                GridManager.Instance.GetGridCoords(gObj.transform.position, out grid, out gCoords);
                grid.Inventory.RemoveObject(gObj, true);
            }
            else if (input.Behavior == RecipeInput.CraftBehavior.PlaceBack)
            {
                gObj.transform.position = gObj.initialDragPosition;
                placedBackObj           = true;

                if (Math.Abs(input.TimeToCraft) > Mathf.Epsilon)
                {
                    gObj.GetComponent <GridObject>().LaunchCraftCooldownFeedback(input.TimeToCraft);
                }
            }
            ++index;
        }

        return(!placedBackObj);
    }
Ejemplo n.º 20
0
    // Create a grid object and add it to the tileset
    public bool CreateGridObject(string objectName, Vector3Int tileLocation, EDirection direction, out GameObject placedObject)
    {
        // Get object data
        KeyValuePair <Transform, GridObjectData> data = GridObjectTypes[objectName];
        Transform      prefab     = data.Key;
        GridObjectData objectData = data.Value;

        // Check if the object fits within the groud boundries
        if (IsObjectValid(objectData, tileLocation, direction))
        {
            // Get the tile dimensions of the object
            Vector3Int dimensions = objectData.GetDimensions(direction);
            int        width      = dimensions.x;
            int        depth      = dimensions.y;
            int        length     = dimensions.z;

            // The offset to the origin of the object in tiles space
            Vector3Int globalOffset = tileLocation + objectData.GetTilesOffset(direction);

            // Calculate the world location of the new grid object
            Vector3 worldLocation = new Vector3();
            TileToWorld(tileLocation, out worldLocation);


            // Create that object and add it to the scene
            Transform sceneObject = GameObject.Instantiate(prefab);
            sceneObject.name     = objectName + ": " + tileLocation.ToString();
            sceneObject.position = worldLocation;
            sceneObject.parent   = transform;
            sceneObject.rotation = Quaternion.AngleAxis((int)direction * 90, Vector3.up);

            // Initialise the grid object variable to be placed into the grid slots
            GridObject obj = new GridObject(sceneObject, objectData, tileLocation, direction);

            for (int y = 0; y < depth; ++y)
            {
                for (int x = 0; x < width; ++x)
                {
                    for (int z = 0; z < length; ++z)
                    {
                        // Only overwrite if the object tile is solid
                        if (objectData.GetIsSolid(x, y, z, direction))
                        {
                            // Get the location of the tile on the grid space
                            Vector3Int globalTileLoc = new Vector3Int(x, y, z) + globalOffset;
                            Tiles[globalTileLoc.x, globalTileLoc.y, globalTileLoc.z] = obj;

                            // Get the location of that tile
                            Vector3 worldLoc = new Vector3();
                            TileToWorld(globalTileLoc, out worldLoc);

                            // Generate a collider at that location
                            BoxCollider collider = ColliderObject.AddComponent <BoxCollider>();
                            collider.center = worldLoc;
                            collider.size   = Vector3.one * TileSize;

                            // Add to the collider objects
                            Colliders[globalTileLoc.x, globalTileLoc.y, globalTileLoc.z] = collider;
                        }
                    }
                }
            }

            // Invoke function
            OnTileAdded?.Invoke(this, new BlockArgs(objectData));

            // Finished placing object
            placedObject = sceneObject.gameObject;
            return(true);
        }
        else
        {
            // Object was not in bounds of the tile grid
            placedObject = null;
            return(false);
        }
    }
Ejemplo n.º 21
0
    //WARNING! NO BUILDMODE CHECK
    private bool BuildObject(GridObjectSaveData GridObjectSavedData)
    {
        if (GridObjectSavedData == null)
        {
            return(false);
        }

        GridObjectID     ID      = (GridObjectID)GridObjectSavedData.ID;
        NodeGridPosition GridPos = new NodeGridPosition(GridObjectSavedData.x, GridObjectSavedData.y);
        int Rot = GridObjectSavedData.Rot;

        GridObjectData ObjectData = IDManager.Instance.GetData(GridObjectSavedData.ID);

        if (ObjectData == null)
        {
            Debug.LogError("ObjectData is null!");
            return(false);
        }

        if (CheckIfOccupied(GetOccupiedNodes(GridPos)) || GridPos == NodeGridPosition.Null)
        {
            return(false);
        }


        Vector3 WorldPos = Grid.GetWorldPointFromNodeGridPosition(GridPos);

        while (Rot < 0)
        {
            Rot += 4;
        }

        Rot %= 4;

        Quaternion Rotation = Quaternion.Euler(0f, Rot * 90f, 0f);


        GridObject GridObj = Instantiate(ObjectData.Prefab, WorldPos, Rotation);

        GridObj.GridPos = GridPos;
        GridObj.Rot     = Rot;

        GridObjects.Add(GridObj);

        if (ID == GridObjectID.wall)
        {
            Wall wall = GridObj.GetComponent <Wall>();
            if (wall != null)
            {
                wall.transform.SetParent(WallParent);
                wall.ShowUpWall(AllWallsShowing);
                AddWall(wall);
            }
        }

        //If the size of the object is more that 1 in any axis
        if (GridObj.Size.x > 1 && GridObj.Size.y > 1)
        {
            //We go through all the occupied nodes to tell them they have been occupied
            foreach (NodeGridPosition OccupiedGridPosition in GridObj.GetOccupiedNodes())
            {
                ObjectGrid[OccupiedGridPosition.x, OccupiedGridPosition.y] = GridObj;
                Node occupiedNode = grid.grid[OccupiedGridPosition.x, OccupiedGridPosition.y];
                occupiedNode.Occupied = true;
                occupiedNode.UpdateWalkable();
            }
        }
        else
        {
            ObjectGrid[GridPos.x, GridPos.y] = GridObj;
            Node node = grid.grid[GridPos.x, GridPos.y];
            node.Occupied = true;
            node.UpdateWalkable();
        }



        return(true);
    }
Ejemplo n.º 22
0
 public BlockArgs(GridObjectData data)
 {
     ObjectData = data;
 }
Ejemplo n.º 23
0
    public override void LoadObjectData(GridObjectData gridObjectData)
    {
        TitleGridObjectData titleGridObjectData = (TitleGridObjectData)gridObjectData;

        titleText.text = $"-----{titleGridObjectData.Title}-----";
    }
Ejemplo n.º 24
0
    // Generates all the objects for the grid object types
    public static void PopulateGridObjectTypes()
    {
        GridObjectTypes = new Dictionary <string, KeyValuePair <Transform, GridObjectData> >();

        // Block
        // -------------------------------------------------------------------------------------------------------
        bool[,,] blockSolidTable = new bool[1, 1, 1] {
            { { true } }
        };
        Vector3Int blockSolidOffset = new Vector3Int(0, 0, 0);

        GridObjectData blockData   = new GridObjectData("Block", blockSolidTable, blockSolidOffset, false, true, 1);
        Transform      blockPrefab = Resources.Load <Transform>(PrefabPath + "Block");

        GridObjectTypes.Add("Block", new KeyValuePair <Transform, GridObjectData>(blockPrefab, blockData));
        // -------------------------------------------------------------------------------------------------------

        // Ramp
        // -------------------------------------------------------------------------------------------------------
        bool[,,] rampSolidTable = new bool[1, 1, 1] {
            { { true } }
        };
        Vector3Int rampSolidOffset = new Vector3Int(0, 0, 0);

        GridObjectData rampData   = new GridObjectData("Ramp", rampSolidTable, rampSolidOffset, false, true, 1);
        Transform      rampPrefab = Resources.Load <Transform>(PrefabPath + "Ramp");

        GridObjectTypes.Add("Ramp", new KeyValuePair <Transform, GridObjectData>(rampPrefab, rampData));
        // -------------------------------------------------------------------------------------------------------

        // Pressure Plate
        // -------------------------------------------------------------------------------------------------------
        bool[,,] pressurePlateSolidTable = new bool[1, 1, 1] {
            { { true } }
        };
        Vector3Int pressurePlateSolidOffset = new Vector3Int(0, 0, 0);

        GridObjectData pressurePlateData   = new GridObjectData("Pressure Plate", pressurePlateSolidTable, pressurePlateSolidOffset, true, false, 5);
        Transform      pressurePlatePrefab = Resources.Load <Transform>(PrefabPath + "PressurePlate");

        GridObjectTypes.Add("Pressure Plate", new KeyValuePair <Transform, GridObjectData>(pressurePlatePrefab, pressurePlateData));
        // -------------------------------------------------------------------------------------------------------

        // Blower
        // -------------------------------------------------------------------------------------------------------
        bool[,,] blowerSolidTable = new bool[1, 1, 1] {
            { { true } }
        };
        Vector3Int blowerSolidOffset = new Vector3Int(0, 0, 0);

        GridObjectData blowerData   = new GridObjectData("Blower", blowerSolidTable, blowerSolidOffset, true, false, 10);
        Transform      blowerPrefab = Resources.Load <Transform>(PrefabPath + "Blower");

        GridObjectTypes.Add("Blower", new KeyValuePair <Transform, GridObjectData>(blowerPrefab, blowerData));
        // -------------------------------------------------------------------------------------------------------

        // Piston
        // -------------------------------------------------------------------------------------------------------
        bool[,,] pistonSolidTable = new bool[1, 1, 1] {
            { { true } }
        };
        Vector3Int pistonSolidOffset = new Vector3Int(0, 0, 0);

        GridObjectData pistonData   = new GridObjectData("Piston", pistonSolidTable, pistonSolidOffset, true, false, 10);
        Transform      pistonPrefab = Resources.Load <Transform>(PrefabPath + "Piston");

        GridObjectTypes.Add("Piston", new KeyValuePair <Transform, GridObjectData>(pistonPrefab, pistonData));
        // -------------------------------------------------------------------------------------------------------

        // Boulder
        // -------------------------------------------------------------------------------------------------------
        bool[,,] boulderSolidTable = new bool[1, 1, 1] {
            { { true } }
        };
        Vector3Int boulderSolidOffset = new Vector3Int(0, 0, 0);

        GridObjectData boulderData   = new GridObjectData("Boulder", boulderSolidTable, boulderSolidOffset, true, false, 10);
        Transform      boulderPrefab = Resources.Load <Transform>(PrefabPath + "Boulder");

        GridObjectTypes.Add("Boulder", new KeyValuePair <Transform, GridObjectData>(boulderPrefab, boulderData));
        // -------------------------------------------------------------------------------------------------------

        // Mortar
        // -------------------------------------------------------------------------------------------------------
        bool[,,] mortarSolidTable = new bool[1, 1, 1] {
            { { true } }
        };
        Vector3Int mortarSolidOffset = new Vector3Int(0, 0, 0);

        GridObjectData mortarData   = new GridObjectData("Mortar", mortarSolidTable, mortarSolidOffset, true, false, 10);
        Transform      mortarPrefab = Resources.Load <Transform>(PrefabPath + "Mortar");

        GridObjectTypes.Add("Mortar", new KeyValuePair <Transform, GridObjectData>(mortarPrefab, mortarData));
        // -------------------------------------------------------------------------------------------------------
    }
Ejemplo n.º 25
0
 public abstract void LoadObjectData(GridObjectData gridObjectData);
Ejemplo n.º 26
0
 public GridObject GetObjectWithData(GridObjectData data)
 {
     return(_objects.Find(o => o.Data == data));
 }