Inheritance: MonoBehaviour
Example #1
0
    public void handleCellDamage(int damage, GridScript.ExplodeType type, CellScript origin)
    {
        Debug.Log("Handing cell damage for " + gridPositionX + " " + gridPositionY);
        if (occupier != null) {
            Debug.Log ("Occupier isn't null");
            ShipScript ship = occupier.GetComponent<ShipScript>();
            //Do one for base as well
            BaseScript based = occupier.GetComponent<BaseScript>();
            if (ship != null )
            {
                Debug.Log ("Ship isn't null");
                if (type == GridScript.ExplodeType.Mine) {
                    Debug.Log("Mine damage");

                    ship.HandleDoubleHit(this,damage, origin);
                } else {
                    ship.HandleHit(this,damage);
                }
            }
            if (based != null)
            {
                based.HandleHit(this,damage);
            }

            //Occupier handles explosion
        }
    }
 public GridSaverScript(GridScript gridScript)
 {
     gridSize = gridScript.gridSize;
     cellSize = gridScript.cellSize;
     grid = new List<List<CellSaverScript>> ();
     for (int x = 0; x < grid.Count; x++) {
         grid.Add (new List<CellSaverScript>());
         for (int y = 0; y < grid.Count; y++) {
             grid[x][y] = new CellSaverScript(gridScript.grid[x,y]);
         }
     }
 }
    public float Hueristic(int x, int y, jAStar.Node start, jAStar.Node goal, GridScript gridScript)
    {
        float dx = Mathf.Abs(x - goal.x);
        float dy = Mathf.Abs(y - goal.y);

        //Tie breaker, cross product implementation
        float dx1   = x - goal.x;
        float dy1   = y - goal.y;
        float dx2   = start.x - goal.x;
        float dy2   = start.y - goal.y;
        float cross = Mathf.Abs(dx1 * dy2 - dx2 * dy1);

        float hueristic = 1.63f * (dx + dy);

        hueristic += cross * 0.001f;
        return(hueristic);
    }
 // Use this for initialization
 void Start()
 {
     packageNumber = Random.Range(0, 4);
     if (Time.timeSinceLevelLoad <= Time.deltaTime)
     {
         Invoke("LateStart", Time.deltaTime / 2f);
     }
     else
     {
         LateStart();
     }
     gs     = FindObjectOfType <GridSize>();
     g      = FindObjectOfType <GridScript>();
     player = GameObject.FindGameObjectWithTag("Player");
     StartCoroutine(Fall());
     fallspeed = 1.3f;
 }
Example #5
0
    public override float Hueristic(int x, int y, Vector3 start, Vector3 goal, GridScript gridScript)
    {
        /*
         *  Developed by Chris Williams
         *
         *  DEPTH FRIST SEARCH DOG BUILD
         *      STATS:
         *          DPTH    *****
         *          BRTH        *
         *          CUTE    *****
         *
         *  BUILD OVERVIEW:
         *
         *      This is a Princess build heavily spec'd in depth first search.
         *      Its hueristic is based on Manhattan distance formula. The Manhattan
         *      distance is a fast-to-compute to exit.
         *
         *      The Manhattan distance is distance between two points if you were
         *      only allowed to walk on paths that were at 90-degree angles from
         *      each other (similar to walking the streets of Manhattan).
         *
         *  Manhattan Distance Formula:
         *      Distance = | cellx - exitx | + | celly - exity |
         *
         *  Build Formula:
         *      Hueristic = (|pos.X - goal.X| + |pos.Y - goal.Y|) ^ 3
         *
         *  Why multiply by a power of 3:
         *      To discourage searching other paths and go untilthe goal is found.
         *      A power of 2 does not create enough distance between the current cost
         *      and a potential new cost and a power greater than 3 does not add anything
         *      more to the depth first search calculation.
         *
         *  Build Strengths:
         *      On maps with costs that are all the sameand have limited obstacles
         *      the early start time compared to other builds will secure you an
         *      easy win.
         *
         *  Build Weaknesses:
         *      On maps with many obstacles this heavily greedy-based approach will
         *      get you in trouble.
         */

        return(Mathf.Pow(Mathf.Abs(x - goal.x) + Mathf.Abs(y - goal.y), 3));
    }
    void Start()
    {
        grid = FindObjectOfType <GridScript>();

        projectile = Instantiate(projectilePrefab, transform.position, Quaternion.identity);
        origin     = transform.position + new Vector3(0, fireOriginHeight, 0);
        target     = transform.position + transform.forward * fireLength;
        if (grid.SquareExists(target.x, target.z))
        {
            target = grid.GetSquare(target.x, target.z).top;
        }

        projectileMesh = projectile.GetComponentInChildren <MeshRenderer>();

        fireTimeRemaining = fireTime;

        buildingLayerMask = LayerMask.GetMask("Buildings");
    }
Example #7
0
    // Use this for initialization
    void Start()
    {
        grid = GameObject.FindGameObjectWithTag("Grid").GetComponent<GridScript>();
        enemyArea = grid.enemyArea;

        float xCoordinate = Random.Range (enemyArea.xMin, enemyArea.xMax-GetComponent<SpriteRenderer>().sprite.bounds.size.x/1.5f);
        float yCoordinate = Random.Range (enemyArea.yMin, enemyArea.yMax-GetComponent<SpriteRenderer>().sprite.bounds.size.y/1.5f);
        wanderingPoint1 = new Vector2 (xCoordinate, yCoordinate);

        xCoordinate = Random.Range (enemyArea.xMin, enemyArea.xMax - GetComponent<SpriteRenderer>().sprite.bounds.size.x / 1.5f);
        yCoordinate = Random.Range (enemyArea.yMin + GetComponent<SpriteRenderer>().sprite.bounds.size.y/1.5f, enemyArea.yMax - GetComponent<SpriteRenderer>().sprite.bounds.size.y/1.5f);
        wanderingPoint2 = new Vector2(xCoordinate, yCoordinate);

        direction = new Vector2 (0, 0);

        timeToPoint1 = wanderingTime / 2;
        timeToPoint2 = wanderingTime;
    }
        public override bool CanUsePower(GridScript gridScript, Grid grid)
        {
            for (int y = 0; y < gridScript.settings.height; y++)
            {
                for (int x = 0; x < gridScript.settings.width; x++)
                {
                    var b = gridScript.Get(x, y);
                    if (b != null && b.block.IsEmpty == false &&
                        b.block.Definition.isGarbage &&
                        b.block.IsConverting == false)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
    public override float Hueristic(int x, int y, Vector3 start, Vector3 goal, GridScript gridScript)
    {
        pos = gridScript.GetGrid();

        GameObject go = pos[x, y];

        Material mat = go.GetComponent <MeshRenderer>().sharedMaterial;

        if (mat.name == "Forest" || mat.name == "Water")
        {
            return(1000000000);
        }

        else
        {
            return(0);
        }
    }
Example #10
0
    // Use this for initialization
    void Start()
    {
        grid      = GameObject.FindGameObjectWithTag("Grid").GetComponent <GridScript>();
        enemyArea = grid.enemyArea;

        float xCoordinate = Random.Range(enemyArea.xMin, enemyArea.xMax - GetComponent <SpriteRenderer>().sprite.bounds.size.x / 1.5f);
        float yCoordinate = Random.Range(enemyArea.yMin, enemyArea.yMax - GetComponent <SpriteRenderer>().sprite.bounds.size.y / 1.5f);

        wanderingPoint1 = new Vector2(xCoordinate, yCoordinate);

        xCoordinate     = Random.Range(enemyArea.xMin, enemyArea.xMax - GetComponent <SpriteRenderer>().sprite.bounds.size.x / 1.5f);
        yCoordinate     = Random.Range(enemyArea.yMin + GetComponent <SpriteRenderer>().sprite.bounds.size.y / 1.5f, enemyArea.yMax - GetComponent <SpriteRenderer>().sprite.bounds.size.y / 1.5f);
        wanderingPoint2 = new Vector2(xCoordinate, yCoordinate);

        direction = new Vector2(0, 0);

        timeToPoint1 = wanderingTime / 2;
        timeToPoint2 = wanderingTime;
    }
    // Use this for initialization
    void Start()
    {
        //guiScr = new GuiManagerScript();
        playersNumber = DataScript.instance.PlayersNumber;
        grid          = new GridScript();
        gameView      = gameObject.AddComponent <GameView>();

        gameView.SetUp(COLORS_COUNT, CELL_COUNT, BASE_POWER_COST, BASE_POWER_DAMAGE, POWERS_COUNT, MOVES_IN_TURN,
                       this, elementsSprites, spr, waitSprite, blockSprite, powerSprites, hpResistanceSprites, menuSpr);
        SetUpPlayers();
        gameView.SetUpGamePanel();
        gameView.SetUpPowerPointsPanel();
        gameView.SetUpHpPanels();
        gameView.UpdateHpPanels(player, player2);
        gameView.UpDateStatePanels(player, player2, powerSprites[5], powerSprites[8]);
        gameView.SetUpExitButton();

        Destroy(DataScript.instance.gameObject);
    }
Example #12
0
    void OnDrawGizmos()
    {
        obj = GameObject.FindGameObjectWithTag("Grid");
        grid = obj.GetComponent<GridScript>();
        width = grid.width;
        height = grid.height;
        Vector3 pos = transform.position ;
        Gizmos.color = color ;

        for ( float y = pos.y  ; y < pos.y + height +0.5f ; y += 1) {
            Gizmos.DrawLine(new Vector3(pos.y +0.5f,y + 0.5f,0.0f),
                            new Vector3(width -0.5f,y  + 0.5f,0.0f));
        }

        for ( float x = pos.x ; x < pos.y + width +0.5f ; x += 1) {
            Gizmos.DrawLine(new Vector3(x + 0.5f,pos.x +0.5f ,0.0f),
                            new Vector3(x + 0.5f,height -0.5f ,0.0f));
        }
    }
Example #13
0
    bool isValidGridPos()
    {
        foreach (Transform child in transform)
        {
            Vector2 v = GridScript.roundVec2(child.position);

            if (!GridScript.insideBorder(v))
            {
                return(false);
            }

            if (GridScript.grid[(int)v.x, (int)v.y] != null &&
                GridScript.grid[(int)v.x, (int)v.y].parent != transform)
            {
                return(false);
            }
        }
        return(true);
    }
Example #14
0
    // member functions
    public void StartNewGame(GameSettings settings)
    {
        // delete current grid in the scene & instantiate new grid
        // using the settings that are read from UI Input fields
        Destroy(GameObject.Find("Grid(Clone)"));
        _gridtf = ((GameObject)Instantiate(GridPrefab, new Vector3(0, 0, 0), Quaternion.identity)).transform;
        _grid   = _gridtf.GetComponent <GridScript>();

        _settings = settings;
        _grid.GenerateMap(_settings);    // grid manager "_grid" generates the map with given settings

        // update handles in companion scripts
        GetComponent <PlayerInput>().Grid = _grid;

        ResetGameState();
        UI.ResetHUD(_flagCount);

        GameObject.Find("Skybox Camera").GetComponent <SkyboxScript>().rotation = GetRandomVector();
    }
Example #15
0
    void Start()
    {
        HittableMinonList = new List<GameObject>();
        // Pedro
        MinionObj = gameObject;
        MinionTilePos = MinionObj.GetComponent<GridScript>();
        movementleft = Move;
        Turn = GameObject.Find("EndTurn");
        Undo = GameObject.Find("UndoButton"); 
        Comfirm = GameObject.Find("ConfirmButton");
        DoOnceForver = true;
        Confirming = false;
        selected = false;
        halo = GetComponent("Halo");
        YetAnotherDoOnce = false;

        // Pedro

        enemy = enemyobj.GetComponent<MinionScript>();
    }
Example #16
0
    public void SetBallPosition(GridScript grid, int column, int row)
    {
        this.grid   = grid;
        this.column = column;
        this.row    = row;

        ballPosition = new Vector3((column * grid.TILE_SIZE) - grid.GRID_OFFSET_X, grid.GRID_OFFSET_Y + (-row * grid.TILE_SIZE), 0);

        if (column % 2 == 0)
        {
            ballPosition.y -= grid.TILE_SIZE * 0.5f;
        }

        transform.localPosition = ballPosition;

        foreach (var go in colorsGO)
        {
            go.SetActive(false);
        }
    }
Example #17
0
    public void LightRangeSliderUpdate(float val)
    {
        GameObject.Find("range_text").GetComponent <Text>().text = "Range: " + val;
        GridScript grid = GameObject.Find("Grid(Clone)").GetComponent <GridScript>();

        foreach (List <Tile> row in grid.Map)
        {
            foreach (Tile tile in row)
            {
                if (tile.GetComponentInChildren <Light>() != null)
                {
                    tile.GetComponentInChildren <Light>().range = val;
                }
                else
                {
                    Debug.Log("NULL LIGHT");
                    return;
                }
            }
        }
    }
Example #18
0
 void updateGrid()
 {
     for (int y = 0; y < GridScript.h; y++)
     {
         for (int x = 0; x < GridScript.w; x++)
         {
             if (GridScript.grid[x, y] != null)
             {
                 if (GridScript.grid[x, y].transform.parent == transform)
                 {
                     GridScript.grid[x, y] = null;
                 }
             }
         }
     }
     foreach (Transform child in transform)
     {
         Vector2 v = GridScript.roundVec(child.position);
         GridScript.grid[(int)v.x, (int)v.y] = child.gameObject;
     }
 }
Example #19
0
        protected override IEnumerator UsePowerOnOpponent(GridScript gridScript, Grid grid, PowerUseParams param)
        {
            // // Wait for effect
            // yield return new WaitForSeconds(0.75f);
            //
            // List<BlockScript> nonEmptyBlocks = new List<BlockScript>();
            // for (int x = 0; x < grid.width; x++)
            // {
            //   for (int y = 0; y < grid.height; y++)
            //   {
            //     var bs = gridScript.Get(x, y);
            //     if (bs != null)
            //     {
            //       var b = bs.block;
            //       if (b != null && b.IsEmpty == false && b.IsBeingRemoved == false)
            //       {
            //         nonEmptyBlocks.Add(bs);
            //       }
            //     }
            //   }
            // }
            //
            // // Mess a % of the grid
            // int blocksToMess = Mathf.FloorToInt(nonEmptyBlocks.Count / 3.5f);
            // nonEmptyBlocks = nonEmptyBlocks.OrderBy(b => Random.Range(0f, 1f)).Take(blocksToMess).ToList();
            //
            // foreach (var bs in nonEmptyBlocks)
            // {
            //   bs.block.ConvertTo(0, 0,
            //     BlockDefinitionBank.Instance.GetRandomNormal(1, grid.width, false,
            //       new List<BlockDefinition>() {bs.block.Definition}));
            //
            //   gridScript.PlayEffectAndSetColor("Explosion",
            //     bs.transform.position, new Vector3(0.5f, 0.5f),
            //     Color.black);
            // }

            EndPowerOnOpponent(gridScript, grid);
            yield return(null);
        }
Example #20
0
    public override float Hueristic(int x, int y, Vector3 start, Vector3 goal, GridScript gridScript)
    {
        float priority;
        float topSum     = 0;
        float bottomSum  = 0;
        float rightSum   = 0;
        float leftSum    = 0;
        float nodesCheck = 0;

        GameObject[,] pos = gridScript.GetGrid();

        if (x > 0 && x < gridScript.gridWidth && y + 1 > 0 && y + 1 < gridScript.gridHeight)
        {
            topSum = gridScript.GetMovementCost(pos[x, y + 1]);
            nodesCheck++;
        }
        if (x > 0 && x < gridScript.gridWidth && y - 1 > 0 && y - 1 < gridScript.gridHeight)
        {
            bottomSum = gridScript.GetMovementCost(pos[x, y - 1]);
            nodesCheck++;
        }
        if (x - 1 > 0 && x - 1 < gridScript.gridWidth && y > 0 && y < gridScript.gridHeight)
        {
            leftSum = gridScript.GetMovementCost(pos[x - 1, y]);
            nodesCheck++;
        }
        if (x + 1 > 0 && x + 1 < gridScript.gridWidth && y > 0 && y < gridScript.gridHeight)
        {
            rightSum = gridScript.GetMovementCost(pos[x + 1, y]);
            nodesCheck++;
        }

        priority = (Mathf.Abs(start.x - goal.x)) + (Mathf.Abs(start.y - goal.y)) * gridScript.costs[0];
        float otherSum = (topSum + bottomSum + leftSum + rightSum) / (nodesCheck * 5);

        priority += (otherSum + gridScript.GetMovementCost(pos[x, y]));
//		Debug.Log("priority = " + priority);

        return(priority);
    }
Example #21
0
    private void OnMouseDrag()
    {
        if (alreadyMoved)
        {
            return;
        }

        Vector2 mouse      = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector2 dragVector = mouse - ( Vector2 )dragStart;

        if (dragVector.magnitude > MIN_DRAG_DISTANCE)
        {
            alreadyMoved = true;
            GridScript grid = GetComponentInParent <GridScript>();

            if (Mathf.Abs(dragVector.x) > Mathf.Abs(dragVector.y))
            {
                if (dragVector.x > 0)
                {
                    grid.Move(Direction.RIGHT);
                }
                else
                {
                    grid.Move(Direction.LEFT);
                }
            }
            else
            {
                if (dragVector.y > 0)
                {
                    grid.Move(Direction.UP);
                }
                else
                {
                    grid.Move(Direction.DOWN);
                }
            }
        }
    }
Example #22
0
    void updateGrid()
    {
        for (int y = 0; y < GridScript.h; ++y)
        {
            for (int x = 0; x < GridScript.w; ++x)
            {
                if (GridScript.grid [x, y] != null)
                {
                    if (GridScript.grid [x, y].parent == transform)
                    {
                        GridScript.grid [x, y] = null;
                    }
                }
            }
        }

        foreach (Transform child in transform)
        {
            Vector2 v = GridScript.roundVec2(child.position);
            GridScript.grid[(int)v.x, (int)v.y] = child;
        }
    }
Example #23
0
    public override float Hueristic(int x, int y, Vector3 start, Vector3 goal, GridScript gridScript)
    {
        float num;

        if (control)
        {
            num = 0;
        }
        else
        {
            //Manhattan
            num = gridScript.costs[0] * Mathf.Abs(x - goal.x) + Mathf.Abs(y - goal.y);
//			float distFromStart = gridScript.costs [0] * Mathf.Abs (x - start.x) + Mathf.Abs (y - start.y);
//			float distFromGoal = gridScript.costs [0] * Mathf.Abs (x - goal.x) + Mathf.Abs (y - goal.y);
//			if (distFromStart < distFromGoal) {
//				num = distFromStart;
//			} else {
//				num = distFromGoal;
//			}
        }
        return(num);
    }
Example #24
0
    bool isValidGridPos()
    {
        //for every single transform
        foreach (Transform child in transform)
        {
            //get the rounded vector value of the transform.
            Vector2 v = GridScript.roundVec2(child.position);

            //See if it's inside the border
            if (!GridScript.insideBorder(v))
            {
                return(false);
            }

            //See if it's in a particular grid cell AND isn't part of the same group
            if (GridScript.grid[(int)v.x, (int)v.y] != null && GridScript.grid[(int)v.x, (int)v.y].parent != transform)
            {
                return(false);
            }
        }
        return(true);
    }
Example #25
0
    void ConfirmPlacement_RPC(int bigID, int smallID, Defines.TURN turn, float time)
    {
        // If not correct turn
        if (GameObject.FindGameObjectWithTag("GUIManager").GetComponent <TurnHandler>().turn != turn)
        {
            return;
        }

        BoardScript      board     = GameObject.Find("Board").GetComponent <BoardScript>();
        BigGridScript    bigGrid   = board.bigGrids[bigID].GetComponent <BigGridScript>();
        GridScript       smallGrid = bigGrid.grids[smallID].GetComponent <GridScript>();
        GUIManagerScript guiScript = GameObject.FindGameObjectWithTag("GUIManager").GetComponent <GUIManagerScript>();

        smallGrid.ConfirmPlacement();
        //guiScript.SetTimer(turn, time);
        guiScript.ResetTimer();

        // Confirms p2 action and ask p2 to execute it.
        if (NetworkManager.IsPlayerOne() && turn == Defines.TURN.P2)
        {
            GetNetworkGameLogic().ConfirmPlacement(bigID, smallID, turn, time);
        }
    }
Example #26
0
    // Start is called before the first frame update
    void Start()
    {
        globals = GameObject.Find("EventSystem").GetComponent <GameStatus>();

        anim = GetComponent <Animator>();
        anim.SetBool("isMoving", true);
        setState(STATE.MOVE);

        Grid = GameObject.Find("Grid").GetComponent <GridScript>();

        // this is used to find a random start position for the slime
        int x, y;

        do
        {
            x = Random.Range(0, Grid.column);
            y = Random.Range(0, Grid.row);
        }while (!Grid.getExists(y, x) && !Grid.onPlayer(y, x));

        CurrentWaypoint = Grid.getWaypoint(new int[] { y, x });

        transform.position = CurrentWaypoint.gameObject.transform.position;
    }
Example #27
0
    void Start()
    {
        fireTimeRemaining = fireTime;

        player.Move(transform.position - transform.forward);

        GridScript grid = FindObjectOfType <GridScript>();

        int length = 0;

        while (grid.SquareExists(transform.position.x + transform.forward.x * (length + 1), transform.position.z + transform.forward.z * (length + 1)))
        {
            length += 1;
        }

        transform.position  += new Vector3(0, fireOriginHeight, 0);
        transform.localScale = new Vector3(1, 1, (length + .5f));

        LayerMask buildingLayerMask = LayerMask.GetMask("Buildings", "Players");

        RaycastHit[] hits = Physics.RaycastAll(transform.position, transform.forward, length + .5f, buildingLayerMask);
        foreach (RaycastHit hit in hits)
        {
            if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Buildings"))
            {
                Destroy(hit.collider.gameObject);
            }
            else if (hit.collider.gameObject == player.otherPlayer.gameObject)
            {
                player.otherPlayer.Damage(damage);
            }
        }

        cylinder  = transform.Find("Cylinder");
        particles = transform.Find("Particles");
    }
Example #28
0
    void Start()
    {
        Blast(transform.forward);
        Blast(-transform.forward);
        Blast(transform.right);
        Blast(-transform.right);

        Vector3Int coords = player.GetCoords();
        GridScript grid   = GameObject.FindObjectOfType <GridScript>();

        // 3x3 area, minus center
        for (int x = coords.x - 1; x <= coords.x + 1; x++)
        {
            for (int z = coords.z - 1; z <= coords.z + 1; z++)
            {
                if ((x != coords.x || z != coords.z) && grid.SquareExists(x, z))
                {
                    grid.SetSquareSurface(x, z, iceSurfacePrefab);
                }
            }
        }

        Destroy(gameObject, 1);
    }
Example #29
0
 public abstract void Action(GameManagerScript gameManager, GridScript grid, TileInformation tile);
Example #30
0
 void Awake()
 {
     mGS = GridScriptObject.GetComponent<GridScript>();
     mTT = TowerTempScriptObject.GetComponent<TowersTemp>();
 }
Example #31
0
 public void Explosion(int x, int y, GridScript.ExplodeType type)
 {
     networkView.RPC ("RPCExplosion",RPCMode.AllBuffered,x,y,(int)type);
 }
Example #32
0
    // Use this for initialization
    void Start()
    {
        gridScript = gameObject.GetComponent<GridScript>();
        rpcScript = gameObject.GetComponent<RPCScript>();

        // Initialize game state variables
        curPlayAction = PlayAction.None;
        curGameState = GameState.Connecting;
        // Run game initialization
        gridInited = false;
        existSelection = false;

        string playerName = PlayerPrefs.GetString("playerName");
        myname = playerName;
        rpcScript.sendPlayerName(myname);
        setPlayerType();

        int LoadedInt = PlayerPrefs.GetInt("LoadedGame");

        if (LoadedInt == 1) {
            //This is a loaded game
            //isLoadedGame = true;
            //Send RPC to say its a loaded game.

            //Change current game state.
            isLoadedGame = true;
            loadFilePath = PlayerPrefs.GetString("LoadedGamePath");
            Debug.Log(loadFilePath);
        }

        player1SetupDone = false;
        player2SetupDone = false;
        player1SetupAcceptance = false;
        player2SetupAcceptance = false;

        setupAccepted = false;

        myRadarCount = 1;
        myKamikazeCount = 1;
        myCruiserCount = 2;
        myDestroyerCount = 3;
        myTorpedoCount = 2;
        myMineLayerCount = 2;
    }
Example #33
0
        public override void Action(GameManagerScript gameManager, GridScript grid, TileInformation tile)
        {
            if (tile != _tile) return;

            var tileList = grid.TileList;
            var tileScript = grid.TileList.FirstOrDefault(x => x.TileInformation == tile);

            if (tileScript != null)
            {
                if (tileScript.Y%2 == 0)
                {
                    if (tileList.Any(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y + 0))
                    {
                        var buffTile = tileList.First(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y + 0);
                        buffTile.TileInformation.DeltaInf *= 2;
                        buffTile.TileInformation.DeltaMoney *= 2;
                    }
                    if (tileList.Any(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y - 1))
                    {
                        var buffTile = tileList.First(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y - 1);
                        buffTile.TileInformation.DeltaInf *= 2;
                        buffTile.TileInformation.DeltaMoney *= 2;
                    }
                    if (tileList.Any(ts => ts.X == tileScript.X + 0 && ts.Y == tileScript.Y - 1))
                    {
                        var buffTile = tileList.First(ts => ts.X == tileScript.X + 0 && ts.Y == tileScript.Y - 1);
                        buffTile.TileInformation.DeltaInf *= 2;
                        buffTile.TileInformation.DeltaMoney *= 2;
                    }
                    if (tileList.Any(ts => ts.X == tileScript.X + 1 && ts.Y == tileScript.Y + 0))
                    {
                        var buffTile = tileList.First(ts => ts.X == tileScript.X + 1 && ts.Y == tileScript.Y + 0);
                        buffTile.TileInformation.DeltaInf *= 2;
                        buffTile.TileInformation.DeltaMoney *= 2;
                    }
                    if (tileList.Any(ts => ts.X == tileScript.X + 0 && ts.Y == tileScript.Y + 1))
                    {
                        var buffTile = tileList.First(ts => ts.X == tileScript.X + 0 && ts.Y == tileScript.Y + 1);
                        buffTile.TileInformation.DeltaInf *= 2;
                        buffTile.TileInformation.DeltaMoney *= 2;
                    }
                    if (tileList.Any(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y + 1))
                    {
                        var buffTile = tileList.First(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y + 1);
                        buffTile.TileInformation.DeltaInf *= 2;
                        buffTile.TileInformation.DeltaMoney *= 2;
                    }
                }
                else
                {
                    if (tileList.Any(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y + 0))
                    {
                        var buffTile = tileList.First(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y + 0);
                        buffTile.TileInformation.DeltaInf *= 2;
                        buffTile.TileInformation.DeltaMoney *= 2;
                    }
                    if (tileList.Any(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y - 1))
                    {
                        var buffTile = tileList.First(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y - 1);
                        buffTile.TileInformation.DeltaInf *= 2;
                        buffTile.TileInformation.DeltaMoney *= 2;
                    }
                    if (tileList.Any(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y - 1))
                    {
                        var buffTile = tileList.First(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y - 1);
                        buffTile.TileInformation.DeltaInf *= 2;
                        buffTile.TileInformation.DeltaMoney *= 2;
                    }
                    if (tileList.Any(ts => ts.X == tileScript.X + 0 && ts.Y == tileScript.Y - 1))
                    {
                        var buffTile = tileList.First(ts => ts.X == tileScript.X + 0 && ts.Y == tileScript.Y - 1);
                        buffTile.TileInformation.DeltaInf *= 2;
                        buffTile.TileInformation.DeltaMoney *= 2;
                    }
                    if (tileList.Any(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y - 1))
                    {
                        var buffTile = tileList.First(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y - 1);
                        buffTile.TileInformation.DeltaInf *= 2;
                        buffTile.TileInformation.DeltaMoney *= 2;
                    }
                    if (tileList.Any(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y - 1))
                    {
                        var buffTile = tileList.First(ts => ts.X == tileScript.X - 1 && ts.Y == tileScript.Y - 1);
                        buffTile.TileInformation.DeltaInf *= 2;
                        buffTile.TileInformation.DeltaMoney *= 2;
                    }
                }
            }

        }
Example #34
0
 // Use this for initialization
 void Start()
 {
     counter = 0.0f;
     grid=GameObject.FindGameObjectWithTag ("Grid").GetComponent<GridScript>();
 }
 public override float Hueristic(int x, int y, Vector3 start, Vector3 goal, GridScript gridScript)
 {
     return(500 * Mathf.Abs(goal.x - x) + Mathf.Abs(goal.y - y));
 }
Example #36
0
 void Awake()
 {
     requestManager = GetComponent <PathRequestManager>();
     grid           = GetComponent <GridScript>();
 }
Example #37
0
 void Awake()
 {
     system = GameObject.FindGameObjectWithTag("System");
     gridScript = system.GetComponent<GridScript>();
     gameScript = system.GetComponent<GameScript>();
 }
Example #38
0
    /** GAMELOOP METHODS **/
    // Use this for initialization
    public void Init()
    {
        system = GameObject.FindGameObjectWithTag("System");
        gameScript = system.GetComponent<GameScript>();
        gridScript = system.GetComponent<GridScript>();
        rpcScript = system.GetComponent<RPCScript>();
        baseSections = new List<GameObject>();
        health = new int[10];

        GameObject[] tBaseSection = new GameObject[10];
        for (int i = 0; i < 10; i++) {
            health [i] = 1;
        }
        foreach (Transform child in transform) {
            string[] section = child.name.Split('_');
            if (section[0] == "BaseSection") {
                int index = int.Parse(section[1]);
                Debug.Log(child.name + " : " + index);
                tBaseSection[index] = child.gameObject;
            }
        }

        baseSections = new List<GameObject>(tBaseSection);
    }
Example #39
0
 public abstract bool CanUse(GameManagerScript gameManager, GridScript grid, TileInformation tile);
Example #40
0
    // Use this for initialization
    public void Init()
    {
        system = GameObject.FindGameObjectWithTag("System");
        gameScript = system.GetComponent<GameScript>();
        gridScript = system.GetComponent<GridScript>();
        rpcScript = system.GetComponent<RPCScript>();
        // Change the size for each sub ship
        speed = maxSpeed;
        health = new int[shipSize];
        InitArmor ();

        // Retrieve prefabs from resources
        explosion = Resources.Load("explosion") as GameObject;
        waterSplash = Resources.Load("water_splash") as GameObject;

        // Add all child sections ship
        GameObject[] tShipSection = new GameObject[shipSize];
        //Correct Order of ship instantiation.
        foreach (Transform child in transform) {
            //Debug.Log(child.name);
            //Debug.Log ("Size: " + shipSize + "and arrysize: " + tShipSection.Length);
            if (child.name == "Stern") tShipSection[0] = child.gameObject;
            if (child.name == "Bow") tShipSection[shipSize-1] = child.gameObject;
            string[] mid = child.name.Split('_');
            if (mid[0] == "Mid") {
                int index = int.Parse(mid[1]);
                //Debug.Log(child.name + " : " + index);
                tShipSection[index] = child.gameObject;
            }
        }
        shipSections = new List<GameObject>(tShipSection);

        for (int i = 0; i < shipSize; i++) {
            Debug.Log(shipSections[i].transform.name + " for index: " + i);
        }

        //		foreach (GameObject s in shipSections) {
        //			Debug.Log(s.transform.name);
        //		}

        //Debug.Log(shipSections[0].name + " : " + shipSections[1].name);
    }
Example #41
0
 void Start()
 {
     grid = FindObjectOfType <GridScript>();
 }
Example #42
0
        public override void Action(GameManagerScript gameManager, GridScript grid, TileInformation tile)
        {
            if (_tile.BonusReceived) return;

            var neighbours = grid.GetNeighbours(grid.TileList.First(t => t.TileInformation == _tile));

            var influenceCount = 0;
            foreach (var neighbour in neighbours)
            {
                influenceCount += neighbour.TileInformation.DeltaInf;
                influenceCount -= neighbour.TileInformation.DeltaNot;
            }

            if (influenceCount >= 10)
            {
                Debug.Log("Got Bonus!!!!");

                _tile.BonusReceived = true;
                gameManager.People += 10;
            }
        }
Example #43
0
 void OnEnable()
 {
     grid = (GridScript)target;
     SelectTile(selectedTile);
 }
Example #44
0
 public override bool CanUse(GameManagerScript gameManager, GridScript grid, TileInformation tile)
 {
     return gameManager.People >= 3;
 }
Example #45
0
 void Awake()
 {
     grid = GetComponent <GridScript>();
 }
Example #46
0
        public override void Action(GameManagerScript gameManager, GridScript grid, TileInformation tile)
        {
            gameManager.Souls += 3;

            gameManager.People -= 3;
            gameManager.Not += 1;

            tile.AreActionsEnabled = false;
        }
 public void SlideCommandLeft()
 {
     //Getting access to the ComandSelect global variables which are attached to the PlayterTerminalObject
     cs = GameObject.Find("PlayerTerminalObject").GetComponent <CommandSelect>();
     //When a pipe is magenta, the pipe is moved left by 1 unit on the grid
     if (selected)
     {
         for (int i = 0; i < CommandSelect.increment; i++)
         {
             collidedPipe1 = GameObject.Find("(" + (X - 1).ToString() + ", " + Y.ToString() + ")");
             gs2           = GameObject.Find("Grid").GetComponent <GridScript>();
             //These if/else conditionals check if there is a pipe or grid boundary that the selected pipe can collide with
             if (collidedPipe1 == null && X > 0)
             {
                 this.MovableComponent.Move(X - 1, Y);
                 pipe1Name = pipe1.name;
                 CommandSelect.collideInput = true;
             }
             else if (collidedPipe1 != null)
             {
                 Debug.Log(collidedPipe1.name);
                 CommandSelect.collideInput = false;
             }
             else
             {
                 CommandSelect.borderInput = true;
             }
         }
         //The Command global variables from GameManager update based on if the selected pipe does or doesn't collide with other objects.
         if (CommandSelect.collideInput == false)
         {
             GameManager.Instance.FullSyntaxCommands += 1;
             GameManager.Instance.TotalCommands      += 1;
         }
         else if (CommandSelect.borderInput == true)
         {
             GameManager.Instance.FullSyntaxCommands += 1;
             GameManager.Instance.TotalCommands      += 1;
         }
         else if (CommandSelect.collideInput == true)
         {
             GameManager.Instance.SuccessCommands += 1;
             GameManager.Instance.TotalCommands   += 1;
         }
     }
     //If no pipe is magenta and a command is passed, the FullSyntaxCommands and TotalCommands values increment by 1
     else
     {
         GameManager.Instance.FullSyntaxCommands += 1;
         GameManager.Instance.TotalCommands      += 1;
     }
     FindObjectOfType <AudioManager>().Play("Slide_Normal");
     cs.TickDown();
     //When count becomes 0, the player loses the level and the lose screen is the only UI element visible
     if (cs.count == 0)
     {
         cs.loseScreen.SetActive(true);
         cs.GameCanvas.SetActive(false);
         GameObject.Find("Grid").SetActive(false);
         gs2.GetComponent <WinDetect>().enabled = false;
     }
 }
Example #48
0
 public override void Action(GameManagerScript gameManager, GridScript grid, TileInformation tile)
 {
     tile.AreActionsEnabled = true;
 }
Example #49
0
 public override bool CanUse(GameManagerScript gameManager, GridScript grid, TileInformation tile)
 {
     return true;
 }
Example #50
0
 /** GAMELOOP METHODS **/
 // Use this for initialization
 public void Init()
 {
     gameObject.renderer.material.color = Color.blue;
     available = true;
     system = GameObject.FindGameObjectWithTag("System");
     gridScript = system.GetComponent<GridScript>();
     gameScript = system.GetComponent<GameScript>();
     rpcScript = system.GetComponent<RPCScript>();
     instanceID = gameObject.GetInstanceID();
 }