Exemplo n.º 1
0
    void Awake()
    {
        if (!map_generator) {
            map_generator = GameObject.FindGameObjectWithTag ("Map").GetComponent<Map_Generator> ();
            map_width = map_generator.width;
            map_height = map_generator.height;
            minSpawnX = map_width / 10;
            minSpawnY = map_height / 10;
        } else {
            map_width = map_generator.width;
            map_height = map_generator.height;
            minSpawnX = map_width / 10;
            minSpawnY = map_height / 10;

        }

        InitializeAllSpawnPositions ();

        if (resourceGrid == null)
            resourceGrid = GameObject.FindGameObjectWithTag ("Map").GetComponent<ResourceGrid> ();

        // Store the paths (List<Node>) in a queue
        //
        //		foreach (List<Node> path in paths) {
        //			pathQueue.Enqueue(path);
        //		}
        //
        //
        //		foreach (List<Node> path in paths) {
        //			kamikazePathQueue.Enqueue(path);
        //		}

        // Create some random Kamikaze positions
        GetRandomKamikazeDestinations ();
    }
Exemplo n.º 2
0
    public void TileToDiscover(string newTileName, int mapPosX, int mapPosY, Transform tileHolder, TileData.Types tileType, int spriteWidth = 0, int spriteHeight = 0)
    {
        // this is called by Resource grid with the proper tile obj
        if (resourceGrid == null)
            resourceGrid = ResourceGrid.Grid;

        tileToSpawn = objPool.GetObjectForType (newTileName, false, Vector3.zero);

        if (tileToSpawn != null) {

            tileToSpawn.transform.position = transform.position;
            tileToSpawn.transform.parent = tileHolder;

            // IF TILE IS NOT EMPTY, IT'S A BUILDING,
            // so it will have a Building Click Handler that needs its pos X and pos Y
            if (tileType != TileData.Types.empty && tileType != TileData.Types.rock)
            {
                Building_Handler bClickHandler = tileToSpawn.GetComponent<Building_Handler> ();
                if (bClickHandler)
                {
                    bClickHandler.mapPosX = mapPosX;
                    bClickHandler.mapPosY = mapPosY;
                    //bClickHandler.resourceGrid = resourceGrid;
                    //bClickHandler.objPool = objPool;
                }

            }

            if (tileType == TileData.Types.capital)
            {
                resourceGrid.transporterGObj = tileToSpawn;
                //// IF IT'S THE TERRAFORMER it will need the master state manager
                //Terraformer_Handler terra = tileToSpawn.GetComponent<Terraformer_Handler>();
        //            if (terra)
                //    terra.master_State = master_state;
            }

            // ADD this tile to the Grid's spawnedTiles array
            if (spriteWidth > 0 && spriteHeight > 0)
            {
                for (int w = -(spriteWidth - 1); w < spriteWidth; w++)
                {
                    for (int h = 0; h < spriteHeight; h++)
                    {
                        if (resourceGrid.spawnedTiles[mapPosX + w, mapPosY + h] == null)
                        {
                            resourceGrid.spawnedTiles[mapPosX + w, mapPosY + h] = tileToSpawn;
                        }

                    }
                }

            }
            else
            {
                resourceGrid.spawnedTiles [mapPosX, mapPosY] = tileToSpawn;
            }

        }
    }
Exemplo n.º 3
0
    public void makeTiles()
    {
        grid = new ResourceGrid();
        setResourceTileColors();
        grid.addTiles(profile);

        //update the map in the profile with the newly created grid. Although that's just weird.
        //Let's see how it goes
        // profile.getComponent<ResourceTileMap>().map.GetComponent<MarineResourceBehavior>().grid = grid;
        colorResource();
    }
Exemplo n.º 4
0
    void Start()
    {
        resourceGrid = GameObject.FindGameObjectWithTag ("Map").GetComponent<ResourceGrid> ();
        capitalPosX = resourceGrid.capitalSpawnX;
        capitalPosY = resourceGrid.capitalSpawnY;
        objPool = GameObject.FindGameObjectWithTag ("Pool").GetComponent<ObjectPool> ();

        // spawning units one below me
        spawnPos = new Vector3 (transform.position.x, transform.position.y - 1f, 0.0f);
        posX = (int)transform.position.x;
        posY = (int)transform.position.y;
    }
Exemplo n.º 5
0
    public void updateTotalResource(ResourceGrid grid)
    {
        float sum = 0f;

        for (int i = 0; i < grid.resourceTiles.Count; i++)
        {
            sum += grid.resourceTiles.ElementAt(i).Value.updatedResource;
        }

        totalResource = sum;

        resourceData.Add(new Vector2(currentYear, totalResource));
        yearlyResourceGraph.yAxis.AxisMaxValue = getSeriesMax(resourceData).y;
        yearlyResourceGraph.xAxis.AxisMaxValue = resourceData.Count > 10 ? resourceData.Count : 10;
        resourceSeries.pointValues.SetList(resourceData);
    }
Exemplo n.º 6
0
    public void DiscoverRock(string newTileName, int mapPosX, int mapPosY, Transform tileHolder, Rock.RockType rockType)
    {
        if (resourceGrid == null)
            resourceGrid = ResourceGrid.Grid;

        rockToSpawn = objPool.GetObjectForType(newTileName, false, Vector3.zero);

        if (rockToSpawn != null)
        {
            rockToSpawn.transform.position = transform.position;
            rockToSpawn.transform.parent = tileHolder;

            SetSpriteForRockOrMineral(rockType);

            resourceGrid.spawnedTiles[mapPosX, mapPosY] = rockToSpawn;
        }
    }
Exemplo n.º 7
0
    void Awake()
    {
        anim = GetComponentInChildren<Animator> ();

        rBody = GetComponent<Rigidbody2D> ();

        mStats.Init ();

        if (Application.loadedLevel == 0)
        {
            isOnShip = true;
        }
        else
        {
            isOnShip = false;
        }

        if (!resourceGrid && !isOnShip)
            resourceGrid = ResourceGrid.Grid;

        equip_wpn = GetComponent<Equip_Item>();
    }
Exemplo n.º 8
0
    void Start()
    {
        if (resourceGrid == null)
        {
            resourceGrid = GameObject.FindGameObjectWithTag("Map").GetComponent <ResourceGrid>();
        }
        if (buildingUI == null)
        {
            buildingUI = GameObject.FindGameObjectWithTag("UI").GetComponent <Building_UIHandler> ();
        }

        if (playerResources == null)
        {
            playerResources = GameObject.FindGameObjectWithTag("Capital").GetComponent <Player_ResourceManager>();
        }

        sr = GetComponent <SpriteRenderer> ();
        lineR.sortingLayerName = sr.sortingLayerName;
        lineR.sortingOrder     = sr.sortingOrder - 1;
        lineR.SetPosition(0, transform.position);
        selecting = true;
    }
    void Awake()
    {
        // Get the Sprite Renderer to be able to change the Sprite's color depending on position
        sr = GetComponent<SpriteRenderer> ();

        // Clear red color for Invalid Position
        invalidPosColor =  new Color(1, 0, 0, 0.5f);

        // Clear green color for Valid Position
        trueColor = new Color(0, 1, 0, 0.5f);

        // Begin as clear Color
        sr.color = Color.clear;

        // Set posY transform to this tile's Spawn Position (passed in by Discover Tile)
        transform.position = spawnPos;

        resourceGrid = ResourceGrid.Grid;
        objPool = ObjectPool.instance;
        build_controller = Build_MainController.Instance;

        mouse_controller = Mouse_Controller.MouseController;
    }
Exemplo n.º 10
0
    public void TileToDiscover(string newTileName, int mapPosX, int mapPosY, Transform tileHolder, ResourceGrid grid,  TileData.Types tileType, GameObject playerCapital)
    {
        // this is called by Resource grid with the proper tile obj
        tileToSpawn = objPool.GetObjectForType (newTileName, false);
        if (tileToSpawn != null) {
            tileToSpawn.transform.position = transform.position;
            tileToSpawn.transform.parent = tileHolder;
            // Give the Tile position relative to the grid map
        //		TileClick_Handler tc = tileToSpawn.GetComponent<TileClick_Handler> ();
        //		tc.mapPosX = mapPosX;
        //		tc.mapPosY = mapPosY;
        //		tc.resourceGrid = grid;
        //		tc.playerUnit = selectedUnit;

        //		// IF TILE IS NOT A ROCK OR EMPTY, IT'S A BUILDING,
            // so it will have a Building Click Handler that needs its pos X and pos Y
            if (tileType != TileData.Types.rock && tileType != TileData.Types.empty && tileType != TileData.Types.mineral) {
                Building_ClickHandler bClickHandler = tileToSpawn.GetComponent<Building_ClickHandler> ();
                bClickHandler.mapPosX = mapPosX;
                bClickHandler.mapPosY = mapPosY;
                bClickHandler.resourceGrid = grid;
                bClickHandler.objPool = objPool;

            }
            if (tileType == TileData.Types.extractor) {
                // IF IT'S AN EXTRACTOR it will ALSO need the extractor variables
                Extractor extra = tileToSpawn.GetComponent<Extractor> ();
                extra.mapPosX = mapPosX;
                extra.mapPosY = mapPosY;
                extra.resourceGrid = grid;
                extra.playerResources = playerCapital.GetComponent<Player_ResourceManager> ();
            }

            // ADD this tile to the Grid's spawnedTiles array
            grid.spawnedTiles [mapPosX, mapPosY] = tileToSpawn;
        }
    }
Exemplo n.º 11
0
    void Start()
    {
        resourceGrid = GameObject.FindGameObjectWithTag ("Map").GetComponent<ResourceGrid> ();

        objPool = GameObject.FindGameObjectWithTag ("Pool").GetComponent<ObjectPool> ();

        parentTransform = transform.parent;

        // spawning units one below me
        //		spawnPos = new Vector3 (transform.position.x-1f, transform.position.y - 1f, 0.0f);
        posX = (int)transform.position.x;
        posY = (int)transform.position.y;

        //init array
        unitsSpawned = new GameObject[maxNumberofUnits];

        unitPositions = new Vector3[maxNumberofUnits];

        // Start already Spawning
        for (int i = 0; i < maxNumberofUnits; i++) {
            Spawn (); 				// spawns four units
        }
    }
Exemplo n.º 12
0
    IEnumerator FindPath(Vector3 startPos, Vector3 targetPos)
    {
        if (grid == null)
            grid = ResourceGrid.Grid;

        //Stopwatch sw = new Stopwatch();
        //sw.Start();

        Vector3[] waypoints = new Vector3[0];
        bool pathSuccess = false;

        Node startNode = grid.NodeFromWorldPoint(startPos);
        Node targetNode = grid.NodeFromWorldPoint(targetPos);

        if (startNode.isWalkable && targetNode.isWalkable)
        {
            Heap<Node> openSet = new Heap<Node>(grid.MaxSize);
            HashSet<Node> closedSet = new HashSet<Node>();

            openSet.Add(startNode);

            while (openSet.Count > 0)
            {
                // Find the Node in the open set with the lowest F cost and remove it
                // using Heap...

                Node currentNode = openSet.RemoveFirstItem();

                // Add to the Closed set
                closedSet.Add(currentNode);

                if (currentNode == targetNode)
                {
                    //sw.Stop();
                    //print("Path found: " + sw.ElapsedMilliseconds + " ms");
                    pathSuccess = true;
                    // Found the end node

                    break;
                }

                foreach (Node neighbor in grid.GetNeighbors(currentNode))
                {
                    // If this neighbor Node is NOT walkable or it is in the CLOSED SET, skip to next neighbor
                    if (!neighbor.isWalkable || closedSet.Contains(neighbor))
                    {
                        continue;
                    }

                    // If this new path is SHORTER than last path OR neighbor is NOT in OPEN SET
                    int newMovementCostToNeighbor = currentNode.gCost + GetDistance(currentNode, neighbor) + (GetMovementPenalty(currentNode, neighbor));

                    if (newMovementCostToNeighbor < neighbor.gCost || !openSet.Contains(neighbor))
                    {
                        neighbor.gCost = newMovementCostToNeighbor;
                        // HCost = distance from this node to the target node
                        neighbor.hCost = GetDistance(neighbor, targetNode);
                        // Set this neighbor's parent so it knows what Node it just chose to path from
                        neighbor.nodeParent = currentNode;

                        if (!openSet.Contains(neighbor))
                        {
                            openSet.Add(neighbor);
                        }
                        else
                        {
                            // if it IS in the Open Set then its value has changed
                            openSet.UpdateItem(neighbor);
                        }

                    }

                }
            }
        }

        yield return null;
        if (pathSuccess)
        {
            waypoints = RetracePath(startNode, targetNode);
        }

        requestManager.FinishedProcessingPath(waypoints, pathSuccess);
    }
Exemplo n.º 13
0
    public void TileToDiscover(string newTileName, int mapPosX, int mapPosY, Transform tileHolder, ResourceGrid grid, TileData.Types tileType, GameObject playerCapital)                // this is called by Resource grid with the proper tile obj
    {
        tileToSpawn = objPool.GetObjectForType(newTileName, false);
        if (tileToSpawn != null)
        {
            tileToSpawn.transform.position = transform.position;
            tileToSpawn.transform.parent   = tileHolder;
            // Give the Tile position relative to the grid map
//		TileClick_Handler tc = tileToSpawn.GetComponent<TileClick_Handler> ();
//		tc.mapPosX = mapPosX;
//		tc.mapPosY = mapPosY;
//		tc.resourceGrid = grid;
//		tc.playerUnit = selectedUnit;

//		// IF TILE IS NOT A ROCK OR EMPTY, IT'S A BUILDING,
            // so it will have a Building Click Handler that needs its pos X and pos Y
            if (tileType != TileData.Types.rock && tileType != TileData.Types.empty)
            {
                tileToSpawn.GetComponent <Building_ClickHandler> ().mapPosX      = mapPosX;
                tileToSpawn.GetComponent <Building_ClickHandler> ().mapPosY      = mapPosY;
                tileToSpawn.GetComponent <Building_ClickHandler> ().resourceGrid = grid;
            }
            if (tileType == TileData.Types.extractor)
            {
                // IF IT'S AN EXTRACTOR it will ALSO need the extractor variables
                tileToSpawn.GetComponent <Extractor> ().mapPosX         = mapPosX;
                tileToSpawn.GetComponent <Extractor> ().mapPosY         = mapPosY;
                tileToSpawn.GetComponent <Extractor> ().resourceGrid    = grid;
                tileToSpawn.GetComponent <Extractor> ().playerResources = playerCapital.GetComponent <Player_ResourceManager> ();
            }



            // ADD this tile to the Grid's spawnedTiles array
            grid.spawnedTiles [mapPosX, mapPosY] = tileToSpawn;
        }
    }
Exemplo n.º 14
0
    // This is the Initializer for Storage Units
    public void InitStorageUnit(int storageCap, Transform _trans, Action<TileData.Types, int> _callback)
    {
        extractorStats = new ExtractorStats(storageCap);
        myTransform = _trans;
        callback = _callback;

        resource_grid = ResourceGrid.Grid;
        b_statusIndicator = GetComponent<Building_Handler>().buildingStatusIndicator;

        // all storage units require an empty material since they can take any
        requiredMaterial = TileData.Types.empty;
    }
Exemplo n.º 15
0
    // this Initializer works for buildings that extract from another building to produce their OWN resource
    public void InitSelfProducer(TileData.Types productType, float rate, int ammnt, int storageCap, int secondStorageCap, int matConsumed, TileData.Types requiredMat,Transform _trans)
    {
        extractorStats = new ExtractorStats(rate, ammnt, storageCap, secondStorageCap, matConsumed);
        resourceType = productType;
        myTransform = _trans;

        resource_grid = ResourceGrid.Grid;
        b_statusIndicator = GetComponent<Building_Handler>().buildingStatusIndicator;

        requiredMaterial = requiredMat;
    }
Exemplo n.º 16
0
    // INITIALIZERS:
    public void Init(TileData.Types r_type, float rate, float power, int ammnt, int storageCap, Transform _trans)
    {
        extractorStats = new ExtractorStats(rate, ammnt, power, storageCap);
        resourceType = r_type;
        myTransform = _trans;

        resource_grid = ResourceGrid.Grid;

        b_statusIndicator = GetComponent<Building_Handler>().buildingStatusIndicator;
    }
Exemplo n.º 17
0
    void Awake()
    {
        //dissasemblyCountDown = dissasemblyTime;

        _state = State.ASSEMBLING;
        s_renderer = GetComponent<SpriteRenderer>();
        s_renderer.color = B;
        FadeIn();

        buildMainController = Build_MainController.Instance;
        objPool = ObjectPool.instance;
        resourceGrid = ResourceGrid.Grid;
    }
Exemplo n.º 18
0
    // HERO/PLAYER LOADING (Called by Resource Grid after Map has been initialized):
    public GameObject SpawnThePlayer(int posX, int posY)
    {
        resourceGrid = ResourceGrid.Grid;
        objPool = ObjectPool.instance;

        Vector3 playerPosition = new Vector3(posX, posY, 0.0f);
        GameObject Hero = objPool.GetObjectForType("Hero Rig", true, playerPosition);

        // After spawning the player Set up the Active Mission requirements and Enemies
        //SetUpMissionAndEnemies();

        /*
        HERE we need what Items the player chose to take with them to the surface.

        We'll need to know Equipped Items: Armor/Space Suit, Weapons, and Tools
        And all Consumable items.

        The correct set needs to be spawned as GameObjects and made children of the Hero GObj.

        We'll need to tell the Player_HeroAttackHandler how many weapons and tools the player has available and link
        the Weapon and Tool variables in that script to the corresponding child gameobjects.

        Default is 2 Weapons, 1 Tool

        Then for the weapons we need to tell its Gun base class to Upgrade any stats if the Weapon was upgraded...

        ...and finally, apply any upgrades to Tools.

        Hero base class.
        Armor.
        List of Weapons.
        List of Tools.
        List of consumables.
        List of abilities.

        upgradeWeapon function (type of upgrade U, type of weapon W){
            Weapons[w].upgrade(U);
        }

        In Weapons class:
        upgrade (type of upgrade U){
            switch(U){
                case attack rate type:
                weapon.stats.attackRate = U.attackRate;
                break;
            }
        }

        ** Solution:

        -Get the Weapon's Component from the name of the weapon ( from Hero class) for each weapon
        - The same for Tools
        - By default Weapon 1 should be active other weapons and tool gameobjects should be inactive

        */
        if (Hero)
        {
            // ***** FIX THIS! Right now this assumes that ALL weapons are guns and have gunstats. There should be a weapon type to
            // differentiate what a Melee weapon's component might need in terms of stats VS. what a gun gets for gunStats.

            // Get the Hero's attack handler.
            Player_HeroAttackHandler hero_attkHandler = Hero.GetComponent<Player_HeroAttackHandler>();

            // Spawn Weapons:

            // Get the first weapon by using the item's name. Name should match the gameobject pre-loaded by Object Pool
            GameObject wpn1 = ObjectPool.instance.GetObjectForType(theHero.weapons[0].itemName, true, Hero.transform.position);
            if (wpn1)
            {
                /* *** TRY THIS FOR ANIMATIONS: ****
                Once the weapon gets instantiated, parent it to the Front Rig's weapon Holder (this transform can be stored as a var on an EquipWeapon script on the Hero parent)
                since this is the default direction.
                Then when the animator goes to activate another rig, EquipWeapon would switch its parent to the correct direction's weapon holder. Since it itself will
                always have a Transform defaulted to 0 the weapon Holder should take care of giving it the correct rotation and position.

                Like so:
                wpn1.transform.SetParent(Hero.GetComponent<Equip_Weapon>().Weapon_Down);

                */

                // Use the method in Equip Weapon to set the default transform to down...
                Hero.GetComponent<Equip_Item>().SwitchRig(Equip_Item.EquipState.DOWN);

                // .. and set the sprite according to this weapon's name
                Hero.GetComponent<Equip_Item>().SwitchSprite(theHero.weapons[0].itemName);

                // Set the Wpn 1's transform to be a child of the Hero...
                wpn1.transform.SetParent(Hero.transform);

                // ... then shift it slightly into position.
                wpn1.transform.localPosition = new Vector3(-0.18f, 0.65f, 0);

                // Then through its Gun base class, set its stats (this will include any upgrades the Hero might have added)
               // wpn1.GetComponent<Player_GunBaseClass>().gunStats = theHero.weapons[0].gunStats;
                if (theHero.weapons[0].gunStats.shootsProjectiles)
                {
                    wpn1.GetComponent<Player_GunBaseClass>().gunStats = new GunStats(theHero.weapons[0].gunStats.startingFireRate,
                                                              theHero.weapons[0].gunStats.startingReloadSpeed,
                                                              theHero.weapons[0].gunStats.startingChamberAmmo,
                                                              theHero.weapons[0].gunStats.damage,
                                                              theHero.weapons[0].gunStats.kickAmmt,
                                                              theHero.weapons[0].gunStats.projectileType);
                }
                else
                {
                    wpn1.GetComponent<Player_GunBaseClass>().gunStats = new GunStats(theHero.weapons[0].gunStats.startingFireRate,
                                                              theHero.weapons[0].gunStats.startingReloadSpeed,
                                                              theHero.weapons[0].gunStats.startingChamberAmmo,
                                                              theHero.weapons[0].gunStats.damage,
                                                              theHero.weapons[0].gunStats.kickAmmt);
                }

                // Assign it to the Hero's attack handler
                hero_attkHandler.AddEquippedItems(wpn1);
            }

            // Keep spawning weapons if the Hero has more equipped...
            if (theHero.weapons.Count > 1)
            {
                for (int i = 1; i < theHero.weapons.Count; i++)
                {
                    // Spawn the next gun...
                    GameObject otherWpn = ObjectPool.instance.GetObjectForType(theHero.weapons[i].itemName, true, Hero.transform.position);

                    if (otherWpn)
                    {
                        otherWpn.transform.SetParent(Hero.transform);

                        otherWpn.transform.localPosition = new Vector3(-0.18f, 0.65f, 0);

                        if (theHero.weapons[0].gunStats.shootsProjectiles)
                        {
                            otherWpn.GetComponent<Player_GunBaseClass>().gunStats = new GunStats(theHero.weapons[0].gunStats.startingFireRate,
                                                                      theHero.weapons[0].gunStats.startingReloadSpeed,
                                                                      theHero.weapons[0].gunStats.startingChamberAmmo,
                                                                      theHero.weapons[0].gunStats.damage,
                                                                      theHero.weapons[0].gunStats.kickAmmt,
                                                                      theHero.weapons[0].gunStats.projectileType);
                        }
                        else
                        {
                            otherWpn.GetComponent<Player_GunBaseClass>().gunStats = new GunStats(theHero.weapons[0].gunStats.startingFireRate,
                                                                      theHero.weapons[0].gunStats.startingReloadSpeed,
                                                                      theHero.weapons[0].gunStats.startingChamberAmmo,
                                                                      theHero.weapons[0].gunStats.damage,
                                                                      theHero.weapons[0].gunStats.kickAmmt);
                        }

                        // Assign it to the Hero's attack handler
                        hero_attkHandler.AddEquippedItems(otherWpn);

                        // ... making sure to set its gameobject to inactive.
                        otherWpn.SetActive(false);
                    }
                }
            }

            // Spawn Tools:
            // Do the same process for the tools.
            GameObject tool1 = ObjectPool.instance.GetObjectForType(theHero.tools[0].itemName, true, Hero.transform.position);
            if (tool1)
            {
                // Set parent to Hero...
                tool1.transform.SetParent(Hero.transform);

                // ... and shift position.
                tool1.transform.localPosition = new Vector3(-0.18f, 0.65f, 0);

                // This gameobject (tool1) needs to start as inactive, so pass in false to its SetActive func.
                tool1.SetActive(false);

                // Assign it to the attack handler.
                hero_attkHandler.AddEquippedItems(tool1);
            }
            // Again we check if more tools are equipped. (The player is limited to two tools at a time)
            if (theHero.tools.Count > 1)
            {
                for (int i = 1; i < theHero.weapons.Count; i++)
                {
                    // Spawn the next Tool...
                    GameObject otherTool = ObjectPool.instance.GetObjectForType(theHero.tools[i].itemName, true, Hero.transform.position);

                    if (otherTool)
                    {
                        otherTool.transform.SetParent(Hero.transform);

                        otherTool.transform.localPosition = new Vector3(-0.18f, 0.65f, 0);

                        // ... making sure to set its gameobject to inactive.
                        otherTool.SetActive(false);

                        // Assign it to the attack handler.
                        hero_attkHandler.AddEquippedItems(otherTool);
                    }
                }
            }

            // Set the Hero's unit stats
            hero_attkHandler.stats = theHero.heroStats;

            // Then set the rest of the necessary values
            Hero.GetComponent<Player_MoveHandler>().resourceGrid = resourceGrid;
            hero_attkHandler.objPool = objPool;
            Hero.GetComponent<Player_PickUpItems>().objPool = objPool;
            resourceGrid.cameraHolder.gameObject.GetComponent<PixelPerfectCam>().followTarget = Hero;
            return Hero;
        }
        else
        {
            return null;
        }
    }
Exemplo n.º 19
0
 void Awake()
 {
     grid = ResourceGrid.Grid;
     requestManager = GetComponent<PathRequestManager>();
 }
Exemplo n.º 20
0
    // Use this for initialization
    void Start()
    {
        // Get the spawn positions from Spawn Point Handler
        if (spwnPtHandler) {
            InitializeSpawnPositions ();
        } else {
            spwnPtHandler = GetComponent<SpawnPoint_Handler>();
            InitializeSpawnPositions();
        }

        if (objPool == null)
            objPool = GameObject.FindGameObjectWithTag ("Pool").GetComponent<ObjectPool> ();

        if (camShake == null)
            camShake = GameObject.FindGameObjectWithTag ("GameController").GetComponent<CameraShake> ();

        if (resourceGrid == null)
            resourceGrid = GameObject.FindGameObjectWithTag ("Map").GetComponent<ResourceGrid> ();

        peaceCountDown = peaceTime;
        waveCountDown = timeBetweenWaves;

        displayTime.text = "Next Wave in: ";

        indicators = new GameObject[wavesInGroup];

        // create initial indicators
        CreateSpawnPointIndicators ();

        maxWaves = waves.Length;

        groupCount = maxWaves / wavesInGroup;
        //		Debug.Log ("WAVE SPAWNER: Group count = " + groupCount);

        state = SpawnState.COUNTING;
    }
Exemplo n.º 21
0
    // Steering Behaviors:
    //  seek : normal follow path to the target
    //  Separate: follows and path but always maintains a distance to a certain other object by shifting its speed
    void OnEnable()
    {
        grid = ResourceGrid.Grid;

        ResetFlagsAndTargets();
    }
Exemplo n.º 22
0
    void Start()
    {
        sightStart = GetComponentInParent<Player_HeroAttackHandler>().sightStart;

        resourceGrid = ResourceGrid.Grid;

        objPool = ObjectPool.instance;

        lineR = sightStart.GetComponent<LineRenderer>();
        // Set line renderer sorting layer
        //lineR.sortingLayerName = GetComponentInParent<SpriteRenderer>().sortingLayerName;

        if (!resourceGrid) Debug.Log("WTF?! No grid attached!");
    }
Exemplo n.º 23
0
 void Awake()
 {
     //		if (!r_sprite_handler) {
     //			r_sprite_handler = GameObject.FindGameObjectWithTag("Map").GetComponent<Resource_Sprite_Handler>();
     //		}
     resourceGrid = ResourceGrid.Grid;
 }
Exemplo n.º 24
0
    void Start()
    {
        // INIT rocksdetected array
        // This assumes that we are only checking tiles ONE TILE OVER in all directions
        rocksDetected = new Vector2[8];

        // In Case Grid is null
        if (resourceGrid == null) {
            resourceGrid = GameObject.FindGameObjectWithTag("Map").GetComponent<ResourceGrid>();
        }

        // In case Building UI is null
        if (buildingUI == null) {
            buildingUI = GameObject.FindGameObjectWithTag ("UI").GetComponent<Building_UIHandler> ();
        }

        // Store the Sprite Renderer for layer management
        sr = GetComponent<SpriteRenderer> ();

        // Line Renderer's layer is set to be UNDER my sprite
        lineR.sortingLayerName = sr.sortingLayerName;
        lineR.sortingOrder = sr.sortingOrder - 1;
        lineR.SetPosition (0, transform.position);

        // Set selecting is true so Line follows Mouse from Start
        //		selecting = true;

        // set Extract Countdown to extraction rate
        extractCountDown = extractRate;
    }
Exemplo n.º 25
0
    void Start()
    {
        // In case Grid is Null
        if (resourceGrid == null) {
            resourceGrid = GameObject.FindGameObjectWithTag("Map").GetComponent<ResourceGrid>();
        }

        // In case Building UI is null
        if (buildingUI == null) {
            buildingUI = GameObject.FindGameObjectWithTag ("UI").GetComponent<Building_UIHandler> ();
        }

        // In case Player Resources is null
        if (playerResources == null) {
            playerResources = GameObject.FindGameObjectWithTag("Capital").GetComponent<Player_ResourceManager>();
        }

        // Store the Sprite Renderer for layer management
        sr = GetComponent<SpriteRenderer> ();

        // Line Renderer's layer is set to be UNDER my sprite
        lineR.sortingLayerName = sr.sortingLayerName;
        lineR.sortingOrder = sr.sortingOrder - 1;
        lineR.SetPosition (0, transform.position);

        //		selecting = true;

        // set Pump Countdown to pump rate
        pumpCountdown = pumpRate;
    }
Exemplo n.º 26
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            DestroyImmediate(gameObject);
        }

        // CHEATING!!!
        curCredits = 1000;
        //Debug.Log ("GM is awake!");

        // Set values for Grid and Object Pool if we are on Planet level
        if (SceneManager.GetActiveScene().name == "Level_Planet")
        {
            resourceGrid = ResourceGrid.Grid;
            objPool = ObjectPool.instance;

        }

        //if (!isHeroCreated)
        //{
        //    isHeroCreated = true;
        //    CreateHero();
        //}

        if (theHero != null)
        {
            Debug.Log("HERO: current BP count = " + theHero.nanoBuilder.blueprintsMap.Count);

        }
    }