Inheritance: MonoBehaviour
Beispiel #1
0
 public Powerup(PowerupScript script)
 {
     Type = script.Type;
     Amount = script.Amount;
     Duration = script.Duration;
     Lifetime = script.Lifetime;
 }
Beispiel #2
0
    /*
     * How is the movement/click on tile going to work?
     * What I thought is that each tile send a message to the manager when a mouseover/click occurs
     * that then decides what is going to happen (since the manager has the information available to do that)
     * and then may send a message back to the tile saying "Change your color" or anything else, but the manager
     * is the one with the logic.
     */
    public void tilePressed(int gridX, int gridY, bool doit = false)
    {
        if (aiActive && currentTurn == 1 && !doit)
        {
            return;
        }

        Debug.Log("Pressed " + gridX + " " + gridY);
        if (activePowerup != null)
        {
            if (!isPowerupClickable(gridX, gridY))
            {
                SoundEffects.sf.playWrong();
                return;
            }
            switch (activePowerup.powerupType)
            {
            case PowerupEnum.CREATE:
                hexGrid[gridY][gridX].RecreateTile();
                break;

            case PowerupEnum.DESTROY:
                hexGrid[gridY][gridX].DestroyTile();
                break;

            case PowerupEnum.TELEPORT:
                players[currentTurn].changeToPosition(gridX, gridY, hexGrid[gridY][gridX].getPlayerPosition());
                checkGetPowerup();
                break;
            }
            activePowerup = null;
            SoundEffects.sf.playPiece();
        }
        else if (checkValidMovement(gridX, gridY))
        {
            movementLeft -= hexGrid[gridY][gridX].consumedMovement();
            hexGrid[players[currentTurn].GridY][players[currentTurn].GridX].degrade();
            players[currentTurn].changeToPosition(gridX, gridY, hexGrid[gridY][gridX].getPlayerPosition());

            checkGetPowerup();
            SoundEffects.sf.playPiece();
        }
        else
        {
            SoundEffects.sf.playWrong();
        }

        if (movementLeft <= 0 && activePowerup == null)
        {
            nextTurn();
        }

        if (isGameWon())
        {
            showVictoryScreenUI((((currentTurn + 1) % 2) + 1));
        }
    }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        blueBeacon   = GameObject.Find("BlueCap");
        yellowBeacon = GameObject.Find("YellowCap");
        greenBeacon  = GameObject.Find("GreenCap");

        blueController   = blueBeacon.GetComponent <PowerupScript> ();
        yellowController = yellowBeacon.GetComponent <PowerupScript> ();
        greenController  = greenBeacon.GetComponent <PowerupScript> ();
    }
Beispiel #4
0
    public void ChooseSpawners(int previousPowerup)
    {
        Transform[] allChildren = GetComponentsInChildren <Transform>();

        spawnRand = Random.Range(2, allChildren.Length);
        randList.Add(spawnRand);
        print(allChildren[spawnRand]);
        PowerupScript callScript = (PowerupScript)allChildren[spawnRand].GetComponent(typeof(PowerupScript));

        callScript.spawnerObj(previousPowerup);
    }
Beispiel #5
0
 private void checkGetPowerup()
 {
     foreach (PowerupScript p in powerups)
     {
         if (p.GridX == players[currentTurn].GridX && p.GridY == players[currentTurn].GridY && p.getable())
         {
             activePowerup = p;
             break;
         }
     }
     if (activePowerup != null)
     {
         powerups.Remove(activePowerup);
         activePowerup.gotten();
     }
 }
    // Use this for initialization
    void Start()
    {
        blueBeacon   = GameObject.Find("BlueCap");
        yellowBeacon = GameObject.Find("YellowCap");
        greenBeacon  = GameObject.Find("GreenCap");

        blueController   = blueBeacon.GetComponent <PowerupScript> ();
        yellowController = yellowBeacon.GetComponent <PowerupScript> ();
        greenController  = greenBeacon.GetComponent <PowerupScript> ();

        offset = new Vector3(0, 2, 10);

        tr1_intro = track1_intro.GetComponent <AudioSource> ();
        tr1_loop  = track1_loop.GetComponent <AudioSource> ();

        //		tr1_loop.audio.PlayDelayed (3f);

        //		StartCoroutine(LateCall());
    }
    // Use this for initialization
    void Start()
    {
        myRigidbody      = GetComponent <Rigidbody> ();
        myCollider       = GetComponent <SphereCollider> ();
        myRenderer       = GetComponent <MeshRenderer>();
        lastCheck        = GameObject.Find("checkpoint_0").transform.position;
        boundaryCounter  = 0;
        isMovementLocked = false;
        isClimbing       = false;

        wipe = new Vector3(2f, 0, 0);

        reduce = new Vector3(0.2f, 0.2f, 0.2f);

        blueBeacon   = GameObject.Find("BlueCap");
        yellowBeacon = GameObject.Find("YellowCap");
        greenBeacon  = GameObject.Find("GreenCap");

        blueController   = blueBeacon.GetComponent <PowerupScript> ();
        yellowController = yellowBeacon.GetComponent <PowerupScript> ();
        greenController  = greenBeacon.GetComponent <PowerupScript> ();
    }
Beispiel #8
0
    void nextTurn()
    {
        foreach (PowerupScript p in powerups)
        {
            p.nextTurn();
        }
        turnCount++;
        movementLeft = 2;
        currentTurn  = (currentTurn + 1) % 2;
        camControl.changeToCharacterPosition(players[currentTurn].transform.position, players[currentTurn].GridY <= (limitY / 2));
        if (turnCount >= 1 && Random.Range(0, 10) < 3)
        {
            PowerupEnum powerup = (PowerupEnum)enumValuesPowerups.GetValue(Random.Range(0, enumValuesPowerups.Length));
            //PowerupEnum powerup = PowerupEnum.TELEPORT;
            int rx    = Random.Range(0, limitX);
            int ry    = Random.Range(0, limitY);
            int tries = 0; //Just to be safe yknow

            while ((!hexGrid[ry][rx].isWalkable() || isPowerupHere(rx, ry)) && tries < 20)
            {
                tries++;
                rx = Random.Range(0, limitX);
                ry = Random.Range(0, limitY);
            }

            if (tries < 20)
            {
                PowerupScript currPowerup = Object.Instantiate <PowerupScript>(dictPowerupToPrefab[powerup]);
                currPowerup.transform.position = hexGrid[ry][rx].getPowerupPosition(currPowerup.powerupType == PowerupEnum.TELEPORT);
                currPowerup.GridX = rx;
                currPowerup.GridY = ry;
                powerups.Add(currPowerup);
            }
        }
        checkGetPowerup();
    }
Beispiel #9
0
    // Use this for initialization
    void Start()
    {
        audioSource.clip = gameSong;
        audioSource.Play();
        audioSource.loop = true;

        activePowerup        = null;
        powerups             = new List <PowerupScript>();
        playerPrefab.manager = this;
        movementLeft         = 2;
        dictTileToPrefab     = new Dictionary <TileTypeEnum, HexagonTile>()
        {
            { TileTypeEnum.FOREST, forestPrefab }, { TileTypeEnum.PLAINS, plainsPrefab },
            { TileTypeEnum.MOUNTAIN, mountainPrefab }, { TileTypeEnum.SWAMP, swampPrefab }, { TileTypeEnum.DESERT, desertPrefabGood }
        };

        dictPowerupToPrefab = new Dictionary <PowerupEnum, PowerupScript>()
        {
            { PowerupEnum.CREATE, createPowerup }, { PowerupEnum.DESTROY, destroyPowerup }, { PowerupEnum.TELEPORT, teleportPowerup }
        };

        enumValuesPowerups = System.Enum.GetValues(typeof(PowerupEnum));

        System.Array enumValues = System.Enum.GetValues(typeof(TileTypeEnum));
        hexGrid = new List <List <HexagonTile> >();
        float sizeX = Mathf.Sqrt(3f);
        float sizeY = 2f;

        validMovParticle   = Object.Instantiate <ParticleSystem>(validMovParticlePrefab);
        invalidMovParticle = Object.Instantiate <ParticleSystem>(invalidMovParticlePrefab);
        validMovParticle.gameObject.SetActive(false);
        invalidMovParticle.gameObject.SetActive(false);

        for (int j = 0; j < limitY; j++)
        {
            List <HexagonTile> currRow = new List <HexagonTile>();
            for (int i = 0; i < limitX; i++)
            {
                TileTypeEnum tileType;
                if (j <= limitY / 2)
                {
                    tileType = (TileTypeEnum)enumValues.GetValue(Random.Range(0, enumValues.Length));
                }
                else
                {
                    tileType = hexGrid[limitY / 2 - (j - limitY / 2)][i].terrainType;
                }
                HexagonTile newTile = Object.Instantiate <HexagonTile>(dictTileToPrefab[tileType]);
                newTile.manager = this;
                Vector3 newPos = new Vector3(sizeX * i + ((1f / 2) * sizeX) * (j % 2),
                                             0, (3f / 4) * sizeY * j);
                newTile.transform.position = newPos;
                newTile.name = "hexagon " + i + " " + j;
                currRow.Add(newTile);
                newTile.gridX = i;
                newTile.gridY = j;
                newTile.setParticles(validMovParticle, invalidMovParticle);
            }
            hexGrid.Add(currRow);
        }

        initializePlayers();
        Camera.main.transform.position = new Vector3(hexGrid[limitY / 2][limitX / 2].transform.position.x,
                                                     Camera.main.transform.position.y,
                                                     hexGrid[limitY / 2][limitX / 2].transform.position.z);
        camControl.changeToCharacterPosition(players[currentTurn].transform.position, players[currentTurn].GridY <= (limitY / 2));
    }
Beispiel #10
0
    private void botAct()
    {
        if (manager.getActivePowerup() != null)
        {
            PowerupScript powerup = manager.getActivePowerup();
            if (powerup.powerupType == PowerupEnum.DESTROY || powerup.powerupType == PowerupEnum.TELEPORT)
            {
                List <IntVector2> moves = manager.possibleMoves(manager.getPlayers()[0].GridX, manager.getPlayers()[0].GridY);
                if (moves.Count > 0)
                {
                    manager.tilePressed(moves[0].x, moves[0].y, true);
                }
                else
                {
                    List <List <HexagonTile> > hexGrid = manager.getHexGrid();
                    foreach (List <HexagonTile> row in hexGrid)
                    {
                        foreach (HexagonTile t in row)
                        {
                            if (!t.isDestroyed())
                            {
                                manager.tilePressed(t.gridX, t.gridY, true);
                                return;
                            }
                        }
                    }
                }
            }
            else
            {
                List <List <HexagonTile> > hexGrid = manager.getHexGrid();
                foreach (List <HexagonTile> row in hexGrid)
                {
                    foreach (HexagonTile t in row)
                    {
                        if (t.isDestroyed())
                        {
                            manager.tilePressed(t.gridX, t.gridY, true);
                            return;
                        }
                    }
                }
            }

            return;
        }

        IntVector2 start = new IntVector2(manager.getPlayers()[1].GridX, manager.getPlayers()[1].GridY);
        IntVector2 end   = new IntVector2(manager.getPlayers()[0].GridX, manager.getPlayers()[0].GridY);
        IntVector2 next  = dijkstra(start, end);

        if (next == null || UnityEngine.Random.Range(0, 10) < 2)
        {
            Debug.Log("Random! " + (next == null));
            List <IntVector2> moves = manager.possibleMoves(manager.getPlayers()[1].GridX, manager.getPlayers()[1].GridY);
            if (moves.Count == 0)
            {
                return;
            }
            IntVector2 move = moves[UnityEngine.Random.Range(0, moves.Count)];
            manager.tilePressed(move.x, move.y, true);
        }
        else
        {
            manager.tilePressed(next.x, next.y, true);
        }
    }