コード例 #1
0
	void Update() {
		if(compass != null) {
			if(cameraman == null) {
				cameraman = compass.getCameraman ();
			}
		}
	}
コード例 #2
0
ファイル: Game.cs プロジェクト: Zylann/GGJ14
    public void Initialize()
    {
        // Finding GameObjects
        m_object_player = GameObject.Find("Player");
        m_object_helpers = GameObject.Find ("Helpers");
        m_object_duckfield = GameObject.Find("Duckfield");
        m_object_audio = GameObject.Find("Audio");
        m_object_cameraman = GameObject.Find("Main Camera");

        // Finding Components
        m_collision_prober = m_object_player.GetComponent<CollisionProber>();
        m_scoring = m_object_player.GetComponent<Scoring>();
        m_health = m_object_player.GetComponent<Health>();
        m_walker = m_object_player.GetComponent<Walker>();
        m_jumper = m_object_player.GetComponent<Jumper>();

        m_time_helper = m_object_helpers.GetComponent<TimeHelper>();
        m_screen_helper = m_object_helpers.GetComponent<ScreenHelper>();

        m_duckfield = m_object_duckfield.GetComponent<DuckField>();

        m_duckization = m_object_audio.GetComponent<DuckizationController>();

        m_cameraman = m_object_cameraman.GetComponent<Cameraman>();
        m_ig_menu = m_object_cameraman.GetComponent<IgMenu>();
    }
コード例 #3
0
    public void Initialize()
    {
        // Finding GameObjects
        m_object_player    = GameObject.Find("Player");
        m_object_helpers   = GameObject.Find("Helpers");
        m_object_duckfield = GameObject.Find("Duckfield");
        m_object_audio     = GameObject.Find("Audio");
        m_object_cameraman = GameObject.Find("Main Camera");

        // Finding Components
        m_collision_prober = m_object_player.GetComponent <CollisionProber>();
        m_scoring          = m_object_player.GetComponent <Scoring>();
        m_health           = m_object_player.GetComponent <Health>();
        m_walker           = m_object_player.GetComponent <Walker>();
        m_jumper           = m_object_player.GetComponent <Jumper>();

        m_time_helper   = m_object_helpers.GetComponent <TimeHelper>();
        m_screen_helper = m_object_helpers.GetComponent <ScreenHelper>();

        m_duckfield = m_object_duckfield.GetComponent <DuckField>();

        m_duckization = m_object_audio.GetComponent <DuckizationController>();

        m_cameraman = m_object_cameraman.GetComponent <Cameraman>();
        m_ig_menu   = m_object_cameraman.GetComponent <IgMenu>();
    }
コード例 #4
0
 /// <summary>
 /// Used by UI elements to return back to overhead view.
 /// </summary>
 public void BackToOverhead()
 {
     SetUpOverhead();
     Cameraman.TakePosition("Overhead View", 0.45f);
     Interface.SwitchMenu("Overhead");
     battle.ChangeState(BattleState.CHOOSING_TARGET, 1f);
 }
コード例 #5
0
 void Update()
 {
     //Sometimes it cant find the camera in the start function, so we have to double check
     if (cameraman == null)
     {
         foreach (PlayerController player in GameObject.FindObjectsOfType <PlayerController>())
         {
             if (player.isLocal())
             {
                 cameraman = player.getCameraman();
             }
         }
     }
     else
     {
         if (local)
         {
             transform.localEulerAngles = new Vector3(0f, 0f, cameraman.RotationsTransform.eulerAngles.y);
         }
         else
         {
             transform.eulerAngles = new Vector3(0f, 0f, cameraman.RotationsTransform.eulerAngles.y);
         }
     }
 }
コード例 #6
0
	void Start() {
		button = GetComponent<Button>();
		button.onClick.AddListener(() => {
			ResetRotation();
		});
		compass = transform.parent.GetComponentInChildren<Compass>();
		cameraman = compass.getCameraman();
	}
コード例 #7
0
    /// <summary>
    /// Begins a new battle.
    /// </summary>
    /// <param name="playersToAdd">The player initializers of players to participate in the battle.</param>
    /// <param name="focus">Whether this battle is the main battle of the game.</param>
    public static void NewBattle(PlayerInitializer[] playersToAdd, bool focus)
    {
        Player[] players = new Player[playersToAdd.Length];
        //state = GameState.PLACING_SHIPS;
        humanPlayers = 0;
        //playerBoardDimensions = Mathf.Clamp(Mathf.FloorToInt(Mathf.Sqrt((float)totalBoardTileLimit / (float)players.Length)), 6, 20);

        //For all players create their own board
        for (int i = 0; i < players.Length; i++)
        {
            players[i] = new GameObject("Player " + (i + 1)).AddComponent <Player>();
            float   angle         = 360 / players.Length * i * Mathf.Deg2Rad;
            Vector3 boardPosition = new Vector3(Mathf.Cos(angle), 0f, Mathf.Sin(angle)) * playerBoardDistanceFromCenter + Vector3.up * playerBoardElevation;
            Player  player        = players[i];
            player.board = new GameObject("Board " + i).AddComponent <Board>();
            player.board.Initialize(playersToAdd[i].boardDimensions, boardPosition, player, playerBoardGridMaterial);
            Cameraman.AddPosition(3f, new Vector3(boardPosition.x, playersToAdd[i].boardDimensions + playerBoardElevation, boardPosition.z), new Vector3(90, 0, 0), "Board " + (i + 1));
            player.color = playersToAdd[i].playerColor;
            player.AI    = playersToAdd[i].AI;
            player.ID    = i;

            if (!player.AI)
            {
                humanPlayers++;
            }

            for (int x = 0; x < players.Length; x++)
            {
                if (x != i)
                {
                    player.hits.Add(x, new List <BoardTile>());
                    player.misses.Add(x, new List <BoardTile>());
                }
            }
        }

        //Add the battle manager GameObject
        Battle battle = new GameObject("Battle").AddComponent <Battle>();

        if (focus)
        {
            mainBattle = battle;
            ChangeState(GameState.PLACING_SHIPS);
            foreach (Battle secondaryBattle in secondaryBattles)
            {
                secondaryBattle.End();
            }

            secondaryBattles = new List <Battle>();
        }
        else
        {
            secondaryBattles.Add(battle);
        }

        battle.Initialize(players);
    }
コード例 #8
0
    // Use this for initialization
    void Start()
    {
        _cameraman = Cameraman.Instance;

        _player1Screen = transform.Find("Panel/Content/Player 1 Screen/Dropdown").GetComponent <Dropdown>();
        _player2Screen = transform.Find("Panel/Content/Player 2 Screen/Dropdown").GetComponent <Dropdown>();

        UpdatePlayerScreens();
    }
コード例 #9
0
 void Start()
 {
     foreach (PlayerController player in GameObject.FindObjectsOfType <PlayerController>())
     {
         if (player.isLocal())
         {
             cameraman = player.getCameraman();
         }
     }
 }
コード例 #10
0
    // Use this for initialization
    void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
            return;
        }

        Instance = this;
    }
コード例 #11
0
    /// <summary>
    /// Prepares the action shot.
    /// </summary>
    public override void Prepare()
    {
        base.Prepare();

        List <Turret> availableTurrets = new List <Turret>();

        if (BattleInterface.battle.recentTurnInformation.hitShips.Count > 0)
        {
            Ship ship = BattleInterface.battle.recentTurnInformation.hitShips[0];
            if (ship.eliminated && (ship.IsRevealedTo(BattleInterface.battle.attackingPlayer) || (GameController.humanPlayers == 1 && !BattleInterface.battle.defendingPlayer.AI) || GameController.humanPlayers == 0))
            {
                killingShot = true;
            }

            if ((GameController.humanPlayers == 1 && !BattleInterface.battle.defendingPlayer.AI) || GameController.humanPlayers == 0 || killingShot)
            {
                BattleInterface.battle.recentTurnInformation.hitShips[0].gameObject.SetActive(true);
            }
        }

        foreach (Ship ship in attackers)
        {
            //ship.PrepareToFireAt(BattleInterface.battle.defendingPlayer.board.tiles[(int)BattleInterface.battle.recentlyShot.x, (int)BattleInterface.battle.recentlyShot.y].worldPosition, BattleInterface.battle.defendingPlayer.board.tiles[(int)BattleInterface.battle.recentlyShot.x, (int)BattleInterface.battle.recentlyShot.y].containedShip);
            ship.PrepareToFireAt(BattleInterface.battle.recentTurnInformation.hitTiles[0].transform.position, BattleInterface.battle.recentTurnInformation.hitShips.Count > 0 ? BattleInterface.battle.recentTurnInformation.hitShips[0] : null);
            foreach (Turret turret in ship.turrets)
            {
                if (turret.canFire && !turret.ignoredByActionCamera)
                {
                    availableTurrets.Add(turret);
                }
            }
        }

        if (availableTurrets.Count > 0)
        {
            selectedTurret = availableTurrets[Random.Range(0, availableTurrets.Count)];
            selectedShip   = selectedTurret.ship;
            if (selectedShip != null && !killingShot)
            {
                Vector3 direction  = selectedTurret.gunDirection;
                float   xzDistance = Vector2.Distance(Vector2.zero, new Vector2(direction.x, direction.z));
                Vector3 angle      = new Vector3(Mathf.Atan2(-direction.y, xzDistance) * Mathf.Rad2Deg, Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg, 0f);

                direction.y = 0f;
                Cameraman.TakePosition(new Cameraman.CameraPosition(0.25f, selectedTurret.transform.position + Vector3.up * 0.3f - direction, angle));
            }
        }



        if (attackers.Count == 0)
        {
            Actionman.EndActionView();
        }
    }
コード例 #12
0
    //private Animator playerAnim;

    void Start()
    {
        //mazeManager = GameObject.FindObjectOfType<MazeManager>();
        //mazeManager.registerPlayer(transform.parent.gameObject);
        agent = GetComponent <NavMeshAgent>();
        nvs   = GameObject.FindObjectOfType <NetworkVariables>();
        cam   = transform.parent.GetComponentInChildren <Cameraman>();
        pSync = transform.parent.GetComponent <PlayerSync>();
        //playerAnim = GameObject.FindGameObjectWithTag ("Player").GetComponentInChildren<Animator> ();
        roomParent = GameObject.Find("Room").transform;
        InvokeRepeating("updateCurrentRoom", 0f, .25f);
    }
コード例 #13
0
 bool FollowProjectile()
 {
     projectile = selectedTurret.recentlyFiredProjectiles[trackedProjectileID];
     if (projectile != null)
     {
         Vector3 direction  = projectile.velocity.normalized;
         float   xzDistance = Vector2.Distance(Vector2.zero, new Vector2(direction.x, direction.z));
         Vector3 angle      = new Vector3(Mathf.Atan2(-direction.y, xzDistance) * Mathf.Rad2Deg, Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg, 0f);
         Cameraman.TakePosition(new Cameraman.CameraPosition(0.22f, projectile.transform.position + Vector3.up, angle));
     }
     return(projectile != null);
 }
コード例 #14
0
    /// <summary>
    /// On battle state change.
    /// </summary>
    /// <param name="switchingFrom">...</param>
    /// <param name="switchingTo">...</param>
    static void OnBattleStateChange(BattleState switchingFrom, BattleState switchingTo)
    {
        switch (switchingFrom)
        {
        case BattleState.SHOWING_HIT_TILE:

            break;

        case BattleState.FIRING:
            foreach (Ship ship in battle.attackingPlayer.livingShips)
            {
                ship.PositionOnPlayingBoard();
                ship.gameObject.SetActive(false);
            }


            break;

        case BattleState.CHOOSING_TILE_TO_SHOOT:
            TorpedoTargetingBattleUIModule.Disable();
            break;
        }

        switch (switchingTo)
        {
        case BattleState.FIRING:
            battle.ChangeState(BattleState.SHOWING_HIT_TILE, 1f);
            Actionman.ActionView();

            break;

        case BattleState.SHOWING_HIT_TILE:
            battle.ChangeState(BattleState.TURN_FINISHED, 1.5f);
            ViewPlayer(battle.defendingPlayer);
            break;

        case BattleState.TURN_FINISHED:
            SetUpOverhead();
            Cameraman.TakePosition("Overhead View", 0.45f);
            Interface.SwitchMenu("Overhead");
            break;

        case BattleState.CHOOSING_TILE_TO_SHOOT:
            break;
        }
    }
コード例 #15
0
    /// <summary>
    /// Shows a player's board.
    /// </summary>
    /// <param name="player">The player, who's board to show.</param>
    static void ViewPlayer(Player player)
    {
        player.SetMacroMarker(-1);

        if (player == battle.attackingPlayer || (GameController.humanPlayers == 1 && !player.AI) || GameController.humanPlayers == 0)
        {
            player.board.Set(BoardState.FRIENDLY);
        }
        else if (!battle.attackingPlayer.AI || GameController.humanPlayers == 0)
        {
            player.board.Set(BoardState.ENEMY);
            TorpedoTargetingBattleUIModule.Enable();
        }
        else
        {
            player.board.Set(BoardState.OVERHEAD);
        }
        Cameraman.TakePosition("Board " + (player.ID + 1), 0.3f);
    }
コード例 #16
0
    /// <summary>
    /// Prepares the action view.
    /// </summary>
    public override void Prepare()
    {
        base.Prepare();
        Vector3 fleetPosition = Vector3.zero;

        if (BattleInterface.battle.recentTurnInformation.hitShips.Count > 0)
        {
            if ((GameController.humanPlayers == 1 && !BattleInterface.battle.defendingPlayer.AI) || GameController.humanPlayers == 0)
            {
                BattleInterface.battle.recentTurnInformation.hitShips[0].gameObject.SetActive(true);
            }
        }

        if (Mathf.Abs(BattleInterface.battle.defendingPlayer.board.transform.position.z) < Mathf.Abs(BattleInterface.battle.defendingPlayer.board.transform.position.x))
        {
            fleetPosition = BattleInterface.battle.defendingPlayer.board.transform.position - Vector3.right * GameController.playerBoardDistanceFromCenter * Mathf.Sign(BattleInterface.battle.defendingPlayer.board.transform.position.x) * 1.5f;
        }
        else
        {
            fleetPosition = BattleInterface.battle.defendingPlayer.board.transform.position - Vector3.forward * GameController.playerBoardDistanceFromCenter * Mathf.Sign(BattleInterface.battle.defendingPlayer.board.transform.position.z) * 1.5f;
        }

        fleetPosition.y = GameController.seaLevel;

        Vector3 targetCameraPosition = Vector3.Lerp(fleetPosition, BattleInterface.battle.recentTurnInformation.hitTiles[0].transform.position, 0.5f);

        targetCameraPosition.y = 35f;

        Cameraman.TakePosition(new Cameraman.CameraPosition(0.45f, targetCameraPosition, Vector3.right * 90f));

        foreach (Ship ship in attackers)
        {
            //ship.PrepareToFireAt(BattleInterface.battle.defendingPlayer.board.tiles[(int)BattleInterface.battle.recentlyShot.x, (int)BattleInterface.battle.recentlyShot.y].worldPosition, BattleInterface.battle.defendingPlayer.board.tiles[(int)BattleInterface.battle.recentlyShot.x, (int)BattleInterface.battle.recentlyShot.y].containedShip);
            float time = ship.PrepareToFireAt(BattleInterface.battle.recentTurnInformation.hitTiles[0].transform.position, BattleInterface.battle.recentTurnInformation.hitShips[0]);
            timeNeeded = (time > timeNeeded) ? time : timeNeeded;
        }

        if (attackers.Count == 0)
        {
            Actionman.EndActionView();
        }
    }
コード例 #17
0
    /// <summary>
    /// Changes the state of the game.
    /// </summary>
    /// <param name="state">The game state to change to.</param>
    public static void ChangeState(GameState state)
    {
        switch (GameController.state)
        {
        }
        GameController.state = state;
        switch (state)
        {
        case GameState.TITLE:
            if (mainBattle)
            {
                BattleInterface.Dettach();
                mainBattle.End();
            }

            Cameraman.TakePosition("Overhead Title View");
            Interface.SwitchMenu("CANCEL_OVERRIDE");
            Interface.SwitchMenu("Title Screen");
            Soundman.ChangeTrack(0, true, true);
            NewBattle(new PlayerInitializer[] { new PlayerInitializer(Color.red, true, 7), new PlayerInitializer(Color.red, true, 7) }, false);
            //NewBattle(new PlayerInitializer[] { new PlayerInitializer(Color.red, true), new PlayerInitializer(Color.red, true), new PlayerInitializer(Color.red, true), new PlayerInitializer(Color.red, true), new PlayerInitializer(Color.red, true) }, false);
            break;

        case GameState.BATTLING:
            Cameraman.TakePosition("Overhead View");
            Interface.SwitchMenu("Overhead");
            Soundman.ChangeTrack(2, true, true);
            break;

        case GameState.PLACING_SHIPS:
            Soundman.ChangeTrack(-1, true, false);
            break;

        case GameState.PLAYER_SELECTION:
            Soundman.ChangeTrack(1, true, false);
            Interface.SwitchMenu("Player Selection Screen");
            PlayerSelector.Reset();
            break;
        }
    }
コード例 #18
0
    /// <summary>
    /// Prepares the action shot.
    /// </summary>
    public override void Prepare()
    {
        base.Prepare();

        foreach (Ship ship in BattleInterface.battle.attackingPlayer.livingShips)
        {
            if (ship.type == ShipType.DESTROYER && ship.lengthRemaining == ship.length)
            {
                selectedDestroyer = (Destroyer)ship;
                break;
            }
        }

        Vector3 position             = BattleInterface.battle.GetTorpedoLaunchPosition();
        bool    alternateOrientation = (Mathf.Abs(position.z - BattleInterface.battle.defendingPlayer.board.transform.position.z) > 1);

        selectedDestroyer.transform.rotation = Quaternion.Euler(new Vector3(0, alternateOrientation ? 90 : 0, 0));

        Vector3 relativeLauncherPos = selectedDestroyer.torpedoLaunchers[0].transform.position - selectedDestroyer.transform.position;
        Vector3 finalPos            = position - relativeLauncherPos;

        finalPos.y = 0;

        selectedDestroyer.transform.position = finalPos;
        selectedDestroyer.PrepareTorpedoLaunchers(new Vector3(BattleInterface.battle.recentTurnInformation.target.x, 0, BattleInterface.battle.recentTurnInformation.target.y) + position);
        selectedDestroyer.gameObject.SetActive(true);
        //selectedDestroyer.FireTorpedoLaunchers();

        Cameraman.TakePosition(new Cameraman.CameraPosition(0.35f, selectedDestroyer.torpedoLaunchers[0].transform.position + Vector3.up * 0.4f - new Vector3(BattleInterface.battle.recentTurnInformation.target.x, 0, BattleInterface.battle.recentTurnInformation.target.y) * 0.5f, new Vector3(20f, Mathf.Atan2(BattleInterface.battle.recentTurnInformation.target.x, BattleInterface.battle.recentTurnInformation.target.y) * Mathf.Rad2Deg, 0f)));

        foreach (BoardTile hit in BattleInterface.battle.recentTurnInformation.torpedoInfo.impacts)
        {
            if (hit.containedShip.eliminated)
            {
                hit.containedShip.gameObject.SetActive(true);
            }
        }
    }
コード例 #19
0
ファイル: ShipPlacer.cs プロジェクト: PistaMista/Battleships
    /// <summary>
    /// Switches to the next player.
    /// </summary>
    /// <returns>Switching successful.</returns>
    static bool NextPlayer()
    {
        playerNumber++;                          //Increment the id of currently handled player
        if (playerNumber > customers.Length - 1) //If there are no more players to handle return false
        {
            customers = null;
            return(false);
        }
        else //If there are more players to handle...
        {
            if (player != null)
            {
                if (battle.isMainBattle)
                {
                    player.board.Set(BoardState.OVERHEAD);
                }
            }

            player = customers[playerNumber];                                //Set up a link to the currently handled player
            if (!player.AI)                                                  //Skip AI players
            {
                Cameraman.TakePosition("Board " + (playerNumber + 1), 0.6f); //Camera takes up a position above the board
                player.board.Set(BoardState.GRID_ONLY);

                InitializeShipsForCurrentPlayer();

                PlacementPreview(shipsToPlace[0]);
                Interface.SwitchMenu("Placing"); //Make sure the interface is set to the placing menu

                return(true);
            }
            else
            {
                return(NextPlayer());
            }
        }
    }
コード例 #20
0
 void EndStageCamera()
 {
     followProjectile = false;
     if (killingShot)
     {
         Vector3 angle              = new Vector3(40f, Mathf.Atan2(finalStageCameraOffset.x, finalStageCameraOffset.z) * Mathf.Rad2Deg, 0f);
         float   elevation          = 15f;
         float   transitionTime     = 0.6f;
         float   horizontalDistance = Mathf.Tan((90f - angle.x) * Mathf.Deg2Rad) * elevation;
         Vector3 position           = BattleInterface.battle.recentTurnInformation.hitTiles[0].transform.position - finalStageCameraOffset * horizontalDistance;
         position.y = elevation;
         Cameraman.TakePosition(new Cameraman.CameraPosition(transitionTime, position, angle));
     }
     else
     {
         Vector3 angle              = new Vector3(45f, Camera.main.transform.eulerAngles.y, 0f);
         float   elevation          = 8f;
         float   transitionTime     = 0.5f;
         float   horizontalDistance = Mathf.Tan((90f - angle.x) * Mathf.Deg2Rad) * elevation;
         Vector3 position           = BattleInterface.battle.recentTurnInformation.hitTiles[0].transform.position + finalStageCameraOffset * horizontalDistance;
         position.y = elevation;
         Cameraman.TakePosition(new Cameraman.CameraPosition(transitionTime, position, angle));
     }
 }
コード例 #21
0
 public virtual void OnSwitchFrom()
 {
     Cameraman.SetBlur(false);
     InputController.securityLevel = 63;
 }
コード例 #22
0
 public virtual void OnSwitchTo()
 {
     Cameraman.SetBlur(blur);
     InputController.securityLevel = inputSecurityLevel;
 }
コード例 #23
0
ファイル: Cameraman.cs プロジェクト: PistaMista/Battleships
 /// <summary>
 /// Function to set the blur by buttons.
 /// </summary>
 /// <param name="enabled"></param>
 public void SetUIBlur(bool enabled)
 {
     Cameraman.SetBlur(enabled);
 }
コード例 #24
0
    void Update()
    {
        if (camMan == null)
        {
            camMan = GameObject.FindObjectOfType <Cameraman>();
            if (camMan != null)
            {
                camMan.renderDistance = dist;
            }
            else
            {
                return;
            }
        }
        else
        {
            camMan.renderDistance = dist;
        }

        //WHY?!?!?!
        //GameObject.FindObjectOfType<Cameraman> ().renderDistance = dist;

        dist = renderDistanceSlider.value;

        renderValueText.text = dist.ToString();

        if (Input.GetKeyDown(KeyCode.Escape) && !IngameChat.showChat)
        {
            escMenu.SetActive(true);
            open = true;
        }

        if (Input.GetKeyUp(KeyCode.Escape) && open)
        {
            closed = false;
        }

        if (Input.GetKeyDown(KeyCode.Escape) && !closed)
        {
            open = false;
            escMenu.SetActive(false);
            closed = true;

            //Close Everything previously open
            exitOP.SetActive(false);
            soundOP.SetActive(false);
            renderDistanceOP.SetActive(false);
        }

        masterLvl = volumeSlider.value;
        Master.audioMixer.SetFloat("Master", masterLvl);

        if (muteOption.isOn)
        {
            NoVolume.TransitionTo(.01f);
            muted = true;
            volumeSlider.value   = -80;
            volumeSlider.enabled = false;
        }
        else if (!muteOption.isOn)
        {
            muted = false;
            Master.TransitionTo(.01f);
            volumeSlider.enabled = true;
        }
    }