public void getStartScene()
    {
        gameSession status = FindObjectOfType <gameSession>();

        status.reset();
        SceneManager.LoadScene(0);
    }
示例#2
0
    private void Start()
    {
        mylevel  = FindObjectOfType <level>();
        session  = FindObjectOfType <gameSession>();
        mySprite = GetComponent <SpriteRenderer>();
        maxHits  = hitSprites.Length + 1;

        if (tag == "Breakable")
        {
            mylevel.countOfBlocks();
        }
    }
示例#3
0
    // Start is called before the first frame update
    void Start()
    {
        sq = Resources.Load <GameObject>("Prefabs/Square");

        rowLabel = Resources.Load <GameObject>("Prefabs/TextPrefab");

        buttonPrefab = Resources.Load <GameObject>("Prefabs/myButton");

        timerText = rowLabel;


        allships = new Ship[5];

        Ship carrier    = new Ship(5);
        Ship battleship = new Ship(4);
        Ship cruiser    = new Ship(3);
        Ship submarine  = new Ship(3);
        Ship destroyer  = new Ship(2);


        allships[4] = carrier;
        allships[3] = battleship;
        allships[2] = cruiser;
        allships[1] = submarine;
        allships[0] = destroyer;



        GameObject anchor  = new GameObject("playergrid");
        GameObject anchor2 = new GameObject("enemygrid");
        GameObject anchor3 = new GameObject("shipselectiongrid");



        //draw player grid
        playerGrid = GenerateGrid(anchor);
        playerGrid.parent.transform.position   = new Vector3(-10f, -10f);
        playerGrid.parent.transform.localScale = new Vector3(1.5f, 1.5f);
        playerGrid.makeClickable();

        //ship selection grid


        Button carrierButton = createWorldButton("Carrier", anchor3, new Vector3(0f, 1f));

        carrierButton.onClick.AddListener(
            () =>
        {
            Debug.Log("Carrier");

            //carrierButton.enabled = false;
            currentlySelectedShip = allships[4];

            currentbutton = carrierButton;
        }
            );



        Button battleshipButton = createWorldButton("Battleship", anchor3, new Vector3(0f, -2f));

        battleshipButton.onClick.AddListener(
            () =>
        {
            Debug.Log("Battleship");

            currentlySelectedShip = allships[3];

            currentbutton = battleshipButton;
        }
            );


        Button submarineButton = createWorldButton("Submarine", anchor3, new Vector3(0f, -5f));

        submarineButton.onClick.AddListener(
            () =>
        {
            Debug.Log("Submarine");
            allships[2].setBackColor(Color.blue);
            currentlySelectedShip = allships[2];

            currentbutton = submarineButton;
        }
            );

        Button cruiserButton = createWorldButton("Cruiser", anchor3, new Vector3(0f, -8f));

        cruiserButton.onClick.AddListener(
            () =>
        {
            Debug.Log("Cruiser");

            currentlySelectedShip = allships[1];

            currentbutton = cruiserButton;
        }
            );

        Button destroyerButton = createWorldButton("Destroyer", anchor3, new Vector3(0f, -11f));

        destroyerButton.onClick.AddListener(
            () =>
        {
            Debug.Log("Destroyer");

            currentlySelectedShip = allships[0];
            currentbutton         = destroyerButton;
        }
            );

        Button removeships = createWorldButton("Remove Fleet", anchor3, new Vector3(0f, -14f));

        removeships.onClick.AddListener(
            () =>
        {
            Debug.Log("Color Change Active");
            foreach (Block b in playerGrid.blocks)
            {
                b.bottomtile.GetComponent <SpriteRenderer>().color = Color.black;
                b.toptile.GetComponent <SpriteRenderer>().color    = Color.white;



                carrierButton.interactable    = true;
                carrier.placed                = false;
                battleshipButton.interactable = true;
                battleship.placed             = false;
                submarineButton.interactable  = true;
                submarine.placed              = false;
                cruiserButton.interactable    = true;
                cruiser.placed                = false;
                destroyerButton.interactable  = true;
                destroyer.placed              = false;

                b.filled = false;
            }
        }
            );


        anchor3.transform.position = new Vector3(10f, -4f);



        enemyGrid = GenerateGrid(anchor2);
        enemyGrid.parent.transform.position   = new Vector3(10f, 10f);
        enemyGrid.parent.transform.localScale = new Vector3(1.5f, 1.5f);
        enemyGrid.makeClickableEnemy();

        //at the moment, theTimer contains the word 'test'
        theTimer = Instantiate(timerText, new Vector3(-18f, 19f), Quaternion.identity);

        //gameSession, which is declared a bit further up.
        session = new gameSession(allships);

        Debug.Log("Hope this runs " + session.gameStarted);

        if (session.gameStarted)
        {
            removeships.interactable = false;
        }

        StartCoroutine(myTurn());
    }
    // Start is called before the first frame update
    void Start()
    {
        //template for a square
        sq = Resources.Load <GameObject>("Prefabs/Square");

        //template for the labels and text that there is on screen
        rowLabel = Resources.Load <GameObject>("Prefabs/TextPrefab");

        //template for the buttons that are loaded on screen
        buttonPrefab = Resources.Load <GameObject>("Prefabs/myButton");

        //add the firebase script to the main camera
        Camera.main.gameObject.AddComponent <FirebaseScript>();

        dbScript = Camera.main.GetComponent <FirebaseScript>();

        //made a copy of rowlabel in the variable timertext
        timerText = rowLabel;



        allships = new Ship[5];

        Ship carrier    = new Ship("Carrier", 5);
        Ship battleship = new Ship("Battleship", 4);
        Ship cruiser    = new Ship("Cruiser", 3);
        Ship submarine  = new Ship("Submarine", 3);
        Ship destroyer  = new Ship("Destroyer", 2);


        allships[4] = carrier;
        allships[3] = battleship;
        allships[2] = submarine;
        allships[1] = cruiser;
        allships[0] = destroyer;



        GameObject anchor  = new GameObject("playergrid");
        GameObject anchor2 = new GameObject("enemygrid");
        GameObject anchor3 = new GameObject("shipselectiongrid");



        //draw player grid
        playerGrid = GenerateGrid(anchor);
        anchor.transform.position   = new Vector3(-10f, -10f);
        anchor.transform.localScale = new Vector3(1.5f, 1.5f);
        playerGrid.makeClickable();

        //ship selection grid


        Button carrierButton = createWorldButton("Carrier", anchor3, new Vector3(0f, 0f));

        carrierButton.onClick.AddListener(
            () =>
        {
            Debug.Log("Carrier");

            //carrierButton.enabled = false;
            currentlySelectedShip = allships[4];
        }
            );

        Button battleshipButton = createWorldButton("Battleship", anchor3, new Vector3(0f, -3f));

        battleshipButton.onClick.AddListener(
            () =>
        {
            Debug.Log("Battleship");

            currentlySelectedShip = allships[3];
        }
            );


        Button submarineButton = createWorldButton("Submarine", anchor3, new Vector3(0f, -6f));

        submarineButton.onClick.AddListener(
            () =>
        {
            Debug.Log("Submarine");
            allships[2].setBackColor(Color.blue);
            currentlySelectedShip = allships[2];
        }
            );

        Button cruiserButton = createWorldButton("Cruiser", anchor3, new Vector3(0f, -9f));

        cruiserButton.onClick.AddListener(
            () =>
        {
            Debug.Log("Cruiser");

            currentlySelectedShip = allships[1];
        }
            );

        Button destroyerButton = createWorldButton("Destroyer", anchor3, new Vector3(0f, -12f));

        destroyerButton.onClick.AddListener(
            () =>
        {
            Debug.Log("Destroyer");

            currentlySelectedShip = allships[0];
        }
            );

        //the position of the ship selection grid.
        anchor3.transform.position = new Vector3(10f, -4f);

        enemyGrid = GenerateGrid(anchor2);
        enemyGrid.parent.transform.position   = new Vector3(10f, 10f);
        enemyGrid.parent.transform.localScale = new Vector3(1.5f, 1.5f);
        enemyGrid.makeClickableEnemy();


        theTimer = Instantiate(timerText, new Vector3(-18f, 19f), Quaternion.identity);

        session = new gameSession(allships);

        StartCoroutine(BeginGame());
    }
示例#5
0
 CommandTypes.Shot => new CommandsExecution.Shots().Execution(gameSession, settings, command, addCommand),
示例#6
0
 CommandTypes.Acceleration => new CommandsExecution.Navigation().Execution(gameSession, settings, command),
示例#7
0
 CommandTypes.StopShip => new CommandsExecution.Navigation().Execution(gameSession, settings, command),
示例#8
0
 CommandTypes.TurnRight => new CommandsExecution.Navigation().Execution(gameSession, settings, command),
示例#9
0
 CommandTypes.MoveForward => new CommandsExecution.Navigation().Execution(gameSession, settings, command),
示例#10
0
 void Start()
 {
     session = FindObjectOfType <gameSession>();
     myball  = FindObjectOfType <ball>();
 }