void Start()
 {
     tgs = TerrainGridSystem.instance;
     isSelectingStart = true;
     tgs.OnCellClick += (grid, cellIndex, buttonIndex) => BuildPath(cellIndex);
     tgs.OnCellEnter += (grid, cellIndex) => ShowLineOfSight(cellIndex);
 }
Exemple #2
0
        void OnEnable()
        {
            _blackTexture           = MakeTex(4, 4, EditorGUIUtility.isProSkin ? new Color(0.18f, 0.18f, 0.18f) : new Color(0.88f, 0.88f, 0.88f));
            _blackTexture.hideFlags = HideFlags.DontSave;
            _headerTexture          = Resources.Load <Texture2D> ("EditorHeader");
            blackStyle = new GUIStyle();
            blackStyle.normal.background = _blackTexture;

            selectionModeOptions  = new string[] { "None", "Territories", "Cells" };
            overlayModeOptions    = new string[] { "Overlay", "Ground" };
            topologyOptions       = new string[] { "Irregular", "Box", "Hexagonal" };
            topologyOptionsValues = new int[] {
                (int)GRID_TOPOLOGY.Irregular,
                (int)GRID_TOPOLOGY.Box,
                (int)GRID_TOPOLOGY.Hexagonal
            };

            tgs = (TerrainGridSystem)target;
            if (tgs.territories == null)
            {
                tgs.Init();
            }
            colorSelection    = new Color(1, 1, 0.5f, 0.85f);
            cellColor         = Color.white;
            cellSelectedIndex = -1;
            isDirty           = serializedObject.FindProperty("isDirty");

            HideEditorMesh();
        }
Exemple #3
0
        void OnEnable()
        {
            _headerTexture = Resources.Load <Texture2D> ("EditorHeader");

            selectionModeOptions = new string[] {
                "None",
                "Territories",
                "Cells"
            };
            overlayModeOptions    = new string[] { "Overlay", "Ground" };
            topologyOptions       = new string[] { "Irregular", "Box", "Hexagonal" };
            topologyOptionsValues = new int[] {
                (int)GRID_TOPOLOGY.Irregular,
                (int)GRID_TOPOLOGY.Box,
                (int)GRID_TOPOLOGY.Hexagonal
            };

            tgs = (TerrainGridSystem)target;
            if (tgs.cells == null)
            {
                tgs.Init();
            }
            sb = new StringBuilder();
            cellSelectedIndices = new List <int> ();
            colorSelection      = new Color(1, 1, 0.5f, 0.85f);
            cellColor           = Color.white;
            isDirty             = serializedObject.FindProperty("isDirty");
            cellSize            = tgs.cellSize;
            HideEditorMesh();
        }
Exemple #4
0
    void Start()
    {
        //TerrainGridSystem reference
        tgs = TerrainGridSystem.instance;

        _player = GameObject.FindWithTag("Player");
    }
Exemple #5
0
    public override void Start()
    {
        base.Start();

        //grabs Sun ref
        sun       = GameObject.FindGameObjectWithTag("Sun");
        sunScript = sun.GetComponent <Sun>();

        //randomizes fullyGrown
        float randomAdd = Random.Range(-0.1f, 0.1f);

        fullyGrownXScale += randomAdd;

        //Random decompDay
        decompositionDay = Random.Range(decompositionDaysMin, decompositionDaysMax);

        //Inventory Manager reference
        inventMan              = GetComponent <inventoryMan>();
        inventMan.isSingle     = false;
        inventMan.interactable = false;
        interactable           = false;

        gameObject.name = "fruit" + seed.name;

        //Grabs rigidbody and sets to kinematic
        rb             = GetComponent <Rigidbody>();
        rb.isKinematic = true;

        //TerrainGridSystem ref
        tgs = TerrainGridSystem.instance;
    }
Exemple #6
0
    public override void Start()
    {
        base.Start();

        //grabs Sun ref
        bed         = GameObject.FindGameObjectWithTag("Bed");
        sleepScript = bed.GetComponent <Bed>();

        //Inventory Manager reference
        inventMan          = GetComponent <inventoryMan>();
        inventMan.isSingle = false;

        inventMan.interactable = true;

        //Random decompDay
        decompositionDay = Random.Range(decompositionDaysMin, decompositionDaysMax);

        //TerrainGridSystem Reference
        tgs = TerrainGridSystem.instance;

        gameObject.name = "seed" + plant.name;

        invent = playerControl.gameObject.GetComponent <Inventory>();

        StartCoroutine(Decompose());
    }
Exemple #7
0
    void Start()
    {
        tgs = TerrainGridSystem.instance;
        tgs.enableRectangleSelection = true;
        tgs.OnRectangleSelection    += SelectCells;

        tgs.OnCellClick += (cellIndex, buttonIndex) => PaintCell(cellIndex);
    }
 protected override void OnBattleLoadedScene()
 {
     base.OnBattleLoadedScene();
     TerrainGridSystem            = TerrainGridSystem.instance;
     TerrainGridSystem.cameraMain = Mono.GetComponentInChildren <Camera>();
     OnSetTerrainGridSystem();
     TerrainGridSystem.GenerateMap();
     CloseMap();
 }
    void Start()
    {
        tgs = TerrainGridSystem.instance;
        state = STATE.MOVESELECT;
        formation = FORMATION.IDLE;
        isSelectingStart = true;
        tgs.OnCellClick += (grid, cellIndex, buttonIndex) => BuildPath(cellIndex);
        //tgs.OnCellEnter += (grid, cellIndex) => ShowLineOfSight(cellIndex);

        unitList = new List<GameObject>();
    }
Exemple #10
0
    // Start is called before the first frame update
    protected void Start()
    {
        tgs = TerrainGridSystem.instance;

        CELL_MASKS["PASSABLE"]          = 1;
        CELL_MASKS["PLAYER"]            = 2;
        CELL_MASKS["ENEMY"]             = 3;
        CELL_MASKS["OTHER"]             = 4;
        CELL_MASKS["IMMOVABLE_ON_LAND"] = 5;
        CELL_MASKS["IMMOVABLE_IN_AIR"]  = 6;
    }
Exemple #11
0
    void Start()
    {
        //TerrainGridSystem reference
        tgs = TerrainGridSystem.instance;

        _player = GameObject.FindWithTag("Player");

        inventMan = GetComponent <inventoryMan>();

        worldMan = GameObject.FindGameObjectWithTag("WorldManager").GetComponent <WorldManager>();
    }
Exemple #12
0
    void Start()
    {
        tgs = TerrainGridSystem.instance;

        stats = ScriptableObject.CreateInstance <UnitStats>();
        unitMovementPoints = stats.movementPoints;

        state            = STATE.MOVESELECT;
        formation        = FORMATION.IDLE;
        isSelectingStart = true;
        tgs.OnCellClick += (grid, cellIndex, buttonIndex) => BuildPath(cellIndex);
        //tgs.OnCellEnter += (grid, cellIndex) => ShowLineOfSight(cellIndex);
    }
Exemple #13
0
    void Start()
    {
        // playAud = GetComponent<playSequence>();
        //grabs Audio
        treeSounds = gameObject.AddComponent <AudioSource>();
        //TerrainGridSystem ref
        tgs            = TerrainGridSystem.instance;
        randomRotation = 60 * Random.Range(0, 6);
        // Clone Sapling prefabs and Instantiate
        groundTile = tgs.CellGetAtPosition(transform.position, true);
        //transform.SetParent ();
        cellIndex = tgs.CellGetIndex(groundTile);
        neighbors = tgs.CellGetNeighbours(groundTile);
        tgs.CellSetCanCross(cellIndex, false);
        //fills up neighborIndexes with the proper cell indexes
        for (int i = 0; i < neighbors.Count; i++)
        {
            int index = tgs.CellGetIndex(neighbors[i]);
            neighborIndexes.Add(index);
            neighbourPos[i] = tgs.CellGetPosition(index);
            //this gives you neighbor cell position
            //can be used to see which cell you’re being given
            //raycast to this position to get the plant collider and get the sequencer
            if (tgs.CellGetTag(index) == 1)
            {
                //this cell has a tree planted, but don’t run this in start
                //send to an array of “plants nearby”

                //for any rule make a bool in plantlife for “isFollowingRule” to see if neighbours are occupied or following a rule already
                //are two adjacent cells in the index occupied that’s a triad
                //if all cells are occupied that’s an arp, arp beats triad
            }
        }


        if (plantedInEditor)
        {
            ageCounter        -= 1;
            transform.position = tgs.CellGetPosition(cellIndex);
            tgs.CellSetTag(cellIndex, 1);
            tgs.CellToggleRegionSurface(cellIndex, true, growingTexture);
        }
        else
        {
            //Set age and fruit
            ageCounter = 0;
            //fruitAmount = 0;
            growthPeriod = 1;
        }
        StartCoroutine(Growth());
    }
Exemple #14
0
    // Update is called once per frame
    protected void Update()
    {
        if (!firstScan)
        {
            tgs = TerrainGridSystem.instance;
            tgs.enableRectangleSelection = false;

            foreach (Cell cell in tgs.cells)
            {
                cellPositions[cell.index] = tgs.CellGetRectWorldSpace(cell.index);
            }

            OnFirstScan.Invoke();

            firstScan = true;
        }
    }
Exemple #15
0
    void Start()
    {
        tgs = TerrainGridSystem.instance;

        for (int i = 0; i < tgs.cells.Count; i++)
        {
            if (tgs.CellGetTag(i) == 0)
            {
                tgs.CellToggleRegionSurface(i, true, groundTexture);
            }
            //if (tgs.CellGetTag(i) == 1)
            //    tgs.CellToggleRegionSurface(i, true, fertileTexture);
            //if (tgs.CellGetTag(i) == 2)
            //tgs.CellToggleRegionSurface(i, true, plantedTexture);

            //if (tgs.CellGetTag(i) == 5)
            //tgs.CellSetCanCross(i, false);
        }
    }
Exemple #16
0
        static void CreateTGSMenuOption(MenuCommand menuCommand)
        {
            GameObject go = Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/TerrainGridSystem"));

            go.name = "Terrain Grid System";
            Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
            Selection.activeObject = go;

            if (Terrain.activeTerrain != null)
            {
                TerrainGridSystem tgs = go.GetComponent <TerrainGridSystem> ();
                if (tgs != null)
                {
                    tgs.terrain = Terrain.activeTerrain;
                }
            }
            else
            {
                go.transform.rotation = Quaternion.Euler(90, 0, 0);
            }
        }
Exemple #17
0
    void Start()
    {
        _player = GameObject.FindGameObjectWithTag("Player");
        fpc     = _player.GetComponent <FirstPersonController>();

        soundBoard = Camera.main.GetComponent <AudioSource>();

        //grabs Sun ref
        bed         = GameObject.FindGameObjectWithTag("Bed");
        sleepScript = bed.GetComponent <Bed>();
        //Random decompDay
        //decompositionDay = Random.Range(decompositionDaysMin, decompositionDaysMax);

        //TerrainGridSystem Reference
        tgs = TerrainGridSystem.instance;

        gameObject.name = "seed" + plant.name;

        inventMan = GetComponent <inventoryMan>();
        invent    = _player.GetComponent <Inventory>();
        //StartCoroutine(Decompose());
    }
Exemple #18
0
    public static Cell CellAtPosition(Vector3 position)
    {
        TerrainGridSystem        tgs           = TerrainGridSystem.instance;
        Dictionary <int, Bounds> cellPositions = new Dictionary <int, Bounds>();


        foreach (Cell cell in tgs.cells)
        {
            cellPositions[cell.index] = tgs.CellGetRectWorldSpace(cell.index);
        }

        foreach (Cell cell in tgs.cells)
        {
            Bounds cellBounds = cellPositions[cell.index];
            if (IsWithinCell(cellBounds, position))
            {
                return(cell);
            }
        }

        throw new UnityException("No Cell at given postion: " + position);
    }
Exemple #19
0
        void OnEnable()
        {
            _blackTexture           = MakeTex(4, 4, new Color(0.18f, 0.18f, 0.18f));
            _blackTexture.hideFlags = HideFlags.DontSave;
            _headerTexture          = Resources.Load <Texture2D> ("EditorHeader");
            blackStyle = new GUIStyle();
            blackStyle.normal.background = _blackTexture;

            selectionModeOptions = new string[] { "None", "Territories", "Cells" };
            overlayModeOptions   = new string[] { "Overlay", "Ground" };
            topologyOptions      = new string[] { "Irregular", "Box", "Rectangular", "Hexagonal" };

            // Load UI icons
            Texture2D[] icons = new Texture2D[5];
            icons [(int)RESHAPE_MODE.NONE]  = Resources.Load <Texture2D> ("IconLock");
            icons [(int)RESHAPE_MODE.ADD]   = Resources.Load <Texture2D> ("IconPen");
            icons [(int)RESHAPE_MODE.MOVE]  = Resources.Load <Texture2D> ("IconMove");
            icons [(int)RESHAPE_MODE.ERASE] = Resources.Load <Texture2D> ("IconEraser");
            icons [(int)RESHAPE_MODE.MERGE] = Resources.Load <Texture2D> ("IconMerge");

            reshapeToolbarIcons = new GUIContent[5];
            reshapeToolbarIcons [(int)RESHAPE_MODE.NONE]  = new GUIContent("", icons [(int)RESHAPE_MODE.NONE], "");
            reshapeToolbarIcons [(int)RESHAPE_MODE.ADD]   = new GUIContent("Add", icons [(int)RESHAPE_MODE.ADD], "Add a new cell to the grid");
            reshapeToolbarIcons [(int)RESHAPE_MODE.MOVE]  = new GUIContent("Move", icons [(int)RESHAPE_MODE.MOVE], "Move a border point");
            reshapeToolbarIcons [(int)RESHAPE_MODE.ERASE] = new GUIContent("Erase", icons [(int)RESHAPE_MODE.ERASE], "Remove a cell");
            reshapeToolbarIcons [(int)RESHAPE_MODE.MERGE] = new GUIContent("Merge", icons [(int)RESHAPE_MODE.MERGE], "Merge two cells");
            reshapeExplanation = new string[5];
            reshapeExplanation [(int)RESHAPE_MODE.ADD]   = "CLICK on the grid to add a new cell ";
            reshapeExplanation [(int)RESHAPE_MODE.MOVE]  = "DRAG a border point on the grid";
            reshapeExplanation [(int)RESHAPE_MODE.ERASE] = "CLICK on any cell to delete it.";
            reshapeExplanation [(int)RESHAPE_MODE.MERGE] = "CLICK on two or more cells in sequence to merge them.";

            tgs = (TerrainGridSystem)target;
            if (tgs.territories == null)
            {
                tgs.Init();
            }
            HideEditorMesh();
        }
Exemple #20
0
    //public int endEnd = 4;


    void Awake()
    {
        //sequencer.enabled = false;
        source = GetComponent <AudioSource>();
        source.outputAudioMixerGroup = mixer;

        tgs = TerrainGridSystem.instance;
        //mixer = Instantiate ();
        farmManager = GameObject.Find("farmManagerNew");
        //octave = farmManager.GetComponent<assignKey>().octave;
        life = GetComponent <NewPlantLife>();
        //sequencer = GameObject.Find ("Sequencer1").GetComponent<AudioHelm.Sequencer> ();
        //note = Random.Range (0, 6);

        bed         = GameObject.FindGameObjectWithTag("Bed");
        sleepScript = bed.GetComponent <Bed>();

        cell   = tgs.CellGetAtPosition(transform.position, true);
        row    = cell.row;
        column = cell.column;

        windDir = sleepScript.windDir;
        WindDirection();

        /*	if (Random.Range(0, 3) == 1)
         *      {
         *              note = 0;
         *              isLeader = true;
         *              start = Random.Range(0, startScale);
         *      }
         *      else
         *      {
         *              note = Random.Range(0, 6);
         *      }
         *
         *      changedSequence = false; */
    }
 void Start()
 {
     tgs = TerrainGridSystem.instance;
     InitialCellBehaviour();
 }
 private void Start()
 {
     tgs = TerrainGridSystem.instance;
 }
Exemple #23
0
 void Start()
 {
     tgs = TerrainGridSystem.instance;
     PositionUnitInCenterOfCell();
 }