Пример #1
0
    public void Start()
    {
        StartTime = Time.time;

        //Get Handle to Camera Effect Classes
        compositeCamera = Camera.main.GetComponent <OutlineComposite>();
        prepassCamera   = Camera.main.GetComponentInChildren <OutlinePrePass>();

        //Fade in for beginning of level
        StartCoroutine(FadeViewIn());

        //Get Handle to BlockPlacer
        BlockPlacer = GetComponent <BlockPlaceManager>();

        BlockPlacer.BlocksPlacedEventHandler += BlocksUI.c_newBlockPlacedEvent;
        BlockPlacer.BlocksPlacedEventHandler += this.c_newBlockPlacedEvent;

        //set BlockPlacer Starting Block Counts
        BlockPlacer.AddAvailableBlocks(BlockTypes.Clay, 5);
        BlockPlacer.AddAvailableBlocks(BlockTypes.Dirt, 5);
        BlockPlacer.AddAvailableBlocks(BlockTypes.Steel, 5);
        BlockPlacer.AddAvailableBlocks(BlockTypes.Clay, 20);
        BlockPlacer.AddAvailableBlocks(BlockTypes.Cloud, 1);

        //set Block UI Starting Block Counts
        //these ones are for testing...make sure to remove
        BlocksUI.AddBlocks(BlockTypes.Clay, 5);
        BlocksUI.AddBlocks(BlockTypes.Dirt, 5);
        BlocksUI.AddBlocks(BlockTypes.Steel, 5);
        BlocksUI.AddBlocks(BlockTypes.Clay, 20);
        BlocksUI.AddBlocks(BlockTypes.Cloud, 1);
    }
Пример #2
0
    public void Grab(GameObject blockPrefab, GameObject slot)
    {
        blockPlacer       = GameObject.Find("BlockPlacer");
        blockPlacerScript = blockPlacer.GetComponent <BlockPlacer>();

        blockPlacerScript.block = blockPrefab;
        blockPlacerScript.slot  = slot;

        blockPlacerScript.isActive = true;
    }
Пример #3
0
    private void Load()
    {
        blockPlacer = FindObjectOfType <BlockPlacer>();

        var list = blockPlacer.LoadArray();

        for (int i = 0; i < list.Count; i = i + 2)
        {
            Debug.Log("x: " + list[i] + ", y: " + list[i + 1]);
        }
    }
Пример #4
0
    public void c_newBlockGatheredEvent(object sender, BlockGatheredEventInfo e)
    {
        //update UI
        BlocksUI.AddBlocks(e.Type, e.Count);

        //Update Block Placement Manager
        BlockPlacer.AddAvailableBlocks(e.Type, e.Count);

        //Update LevelStats
        currentStats.BlocksCollected += e.Count;

        //Verify UI and Block Placement Manager are in sync??
    }
Пример #5
0
    public override void ProcessPlayingInputs(float horizontal, float vertical, float switchblock, bool placeblock, bool jump, Vector3 courseAdjust, Vector3 fineAdjust, Vector3 mousePosition)
    {
        if (switchblock >= 0.1f)
        {
            BlocksUI.RotateBlocksRight();

            //set active block type in block place manager to match what's showing in the UI
            BlockTypes active = BlocksUI.ActiveBlockType();
            BlockPlacer.SetSelectedBlockType(active);
        }
        else if (switchblock <= -0.1f)
        {
            BlocksUI.RotateBlocksLeft();

            //set active block type in block place manager to match what's showing in the UI
            BlockTypes active = BlocksUI.ActiveBlockType();
            BlockPlacer.SetSelectedBlockType(active);
        }

        //z = 0 when that input type is being used
        if (mousePosition.z == 0)
        {
            Vector2 world = Camera.main.ScreenToWorldPoint(mousePosition);
            BlockPlacer.SetBlockCursorPosition(world);
        }
        else
        {
            if (courseAdjust.z == 0)
            {
            }
            else if (fineAdjust.z == 0)
            {
            }
        }

        if (placeblock && !BlockPlacer.InBlockPlaceMode)
        {
            compositeCamera.enabled = true;
            prepassCamera.gameObject.SetActive(true);
            BlockPlacer.BeginBlockPlaceMode();
        }
        else if (!placeblock && BlockPlacer.InBlockPlaceMode)
        {
            BlockPlacer.EndBlockPlaceMode();
        }

        //player movement
        Player.InputDirection = new Vector2(horizontal, vertical);
        Player.ProcessJumpInput(jump);
    }
Пример #6
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        placer = target as BlockPlacer;

        if (GUILayout.Button("Generate Blocks"))
        {
            if (placer.blocksPile != null && placer.blocksPile.transform.parent == placer.transform)
            {
                DestroyBlocks();
            }

            GameObject go = placer.GenerateBlocks();
            Undo.RegisterCreatedObjectUndo(go, "Generate Blocks");
            EditorUtility.SetDirty(placer);
        }
        if (GUILayout.Button("Destroy Blocks"))
        {
            DestroyBlocks();
        }
    }
Пример #7
0
    private void InstantiateBlocks()
    {
        string path = "Assets/Prefabs";
        //string prefabName = "Block";
        GameObject parent = GameObject.FindGameObjectWithTag("Blocks");

        blockPlacer = FindObjectOfType <BlockPlacer>();
        var list  = blockPlacer.LoadArray();
        var names = blockPlacer.LoadNames();

        for (int i = 0, j = 0; i < list.Count; i = i + 2, j++)
        {
            Object prefab = AssetDatabase.LoadAssetAtPath(path + "/"
                                                          + names[j].Substring(0, names[j].Length - 7)
                                                          + ".prefab", typeof(GameObject));
            if (prefab != null)
            {
                GameObject obj = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
                obj.transform.SetParent(parent.transform);
                obj.transform.position = new Vector2(list[i], list[i + 1]);
            }
        }
    }
 public void Execute()
 {
     if (action == Action.Toggle)
     {
         BlockPlacer.TogglePlace();
         enabled = !enabled;
     }
     else if (action == Action.Place && enabled && amountOfBlocks >= 1)
     {
         if (Level.LevelManager.PlaceBlock())
         {
             amountOfBlocks--;
         }
     }
     else if (action == Action.Remove && enabled)
     {
         if (Level.LevelManager.RemoveBlock())
         {
             amountOfBlocks++;
         }
     }
     BlockPlacer.AmountOfBlocks(amountOfBlocks);
 }
Пример #9
0
    public byte getBlock(int y, float mountainValue, float blobValue)
    {
        BlockPlacer bestBidder = null;
        float       bestBid    = 0;

        for (int a = 0; a < blockPlacers.Length; a++)
        {
            float bid = blockPlacers[a].Bid(y, mountainValue, blobValue);
            if (bid > bestBid)
            {
                bestBid    = bid;
                bestBidder = blockPlacers[a];
            }
        }

        if (bestBidder == null)
        {
            return(0);
        }
        else
        {
            return((byte)bestBidder.block);
        }
    }
Пример #10
0
 void Awake()
 {
     instance = this;
 }
Пример #11
0
 void Start()
 {
     rb = GetComponent <Rigidbody2D>();
     bp = GameObject.Find("Blocks").GetComponent <BlockPlacer>();
     Reset();
 }
Пример #12
0
 void Start()
 {
     //This assigns the static reference
     BlockPlacer.obj = this;
 }
Пример #13
0
 void Start()
 {
     blocks          = new ArrayList();
     BlockPlacer.obj = this;
 }
Пример #14
0
    private void Save()
    {
        blockPlacer = FindObjectOfType <BlockPlacer>();

        blockPlacer.SaveArray();
    }
Пример #15
0
 private void Start()
 {
     blockPlacer = FindObjectOfType <BlockPlacer>();
 }
Пример #16
0
    void Start()
    {
        //This assigns the static reference
        BlockPlacer.obj = this;


        //get difficulty setting from script variables
        if (Difficulty == "easy")
        {
            model = model_easy;
        }
        if (Difficulty == "medium")
        {
            model = model_medium;
        }
        if (Difficulty == "hard")
        {
            model = model_hard;
        }
        else
        {
            Debug.Log("Invalid difficulty setting: options are easy, medium, hard");
        }

        //traverse through 3D model array and put the vectors into a list

        //Define the reference position:
        float origin_x = 0f;
        float origin_y = -.6f;
        float origin_z = 1.05f;

        int uBound0 = model.GetUpperBound(0);
        int uBound1 = model.GetUpperBound(1);
        int uBound2 = model.GetUpperBound(2);

        //Iterate through the 3D model array and place blocks where a 1 appears
        for (int z = 0; z <= uBound0; z++)
        {
            for (int y = 0; y <= uBound1; y++)
            {
                for (int x = 0; x <= uBound2; x++)
                {
                    if (model[z, y, x] == 1)
                    {
                        Vector3 newVector = new Vector3(origin_x + (float)(x * .15), origin_z + (float)(z * .15), origin_y + (float)(y * .15));

                        //add the vector to the list:
                        modelVectors.Add(newVector);
                    }
                }
            }
        }

        //add the first block of the model:

        //Round the placement so the blocks snap to the grid
        Vector3 placeModel = new Vector3(Mathf.Round(modelVectors[counter].x / Grid.x) * Grid.x,
                                         Mathf.Round(modelVectors[counter].y / Grid.y) * Grid.y,
                                         Mathf.Round(modelVectors[counter].z / Grid.z) * Grid.z);

        //Instantiate the block and save it so that we can do other stuff with it later
        modelBlock       = (GameObject)GameObject.Instantiate(tutorialBlock, placeModel, Quaternion.Euler(Vector3.zero));
        modelBlockVector = placeModel;

        counter += 1;
    }
Пример #17
0
    // Use this for initialization
    void Start()
    {
        BlockPlacer BP = Camera.main.transform.GetComponent <BlockPlacer>();

        BP.LoadData();
    }