// Use this for initialization
 void Start()
 {
     console = FindObjectOfType<BoltConsole>();
     debugInfo = FindObjectOfType<Bolt.DebugInfo>();
     BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
     field = typeof(BoltConsole).GetField("visible", flags);
 }
Example #2
0
 //TODO: start combat here.
 public override void OnEvent(FinalBoss evnt)
 {
     BoltConsole.Write("Final Boss battle (not yet implemented so everyone dies)");
     BoltConsole.Write("Final Boss battle (not yet implemented so everyone dies)");
     PanelHolder.instance.displayNotify("Final Boss Battle", "(not yet implemented so everyone dies)", "OK");
     playerSpellcaster = playerEntity.GetComponent <Player>().spellcaster;
     playerSpellcaster.TakeDamage((int)(playerSpellcaster.fCurrentHealth));
     SpellCaster.savePlayerData(playerSpellcaster);
 }
Example #3
0
    public int startNewTurn()
    {
        turn_i++;

        //If everyone moved this turn, then a year/round has passed.
        if (turn_i >= turnOrder.Count)
        {
            if (state.YearsUntilNextEvent <= 1 && !GlobalEventHappened && !savedByHero)
            {
                BoltConsole.Write("Global EVENT happening!!");
                GlobalEventHappened = true;
                globalEvents.executeGlobalEvent();
                //needToNotifyPlayersNewEvent = true;
            }
            else if (state.YearsUntilNextEvent <= 1 && !GlobalEventHappened && savedByHero)
            {
                NetworkManager.s_Singleton.ResolveCrisis(currentCrisis, hero);
                GlobalEventHappened = true;
            }
            BoltConsole.Write("NEW ROUND!!!!!");
            turn_i = 0;
            if (!globalEvents.AllCrisisHappened())
            {
                yearsUntilNextEvent--;
                state.YearsUntilNextEvent--;
            }
            else
            {
                //Temporary hack.
                yearsUntilNextEvent       = 100;
                state.YearsUntilNextEvent = 100;
            }


            if (PeacefulYear)
            {
                BoltConsole.Write("Peaceful year ended");
                PeacefulYear        = false;
                GlobalEventHappened = false;
                bool crisisPrepared = globalEvents.PrepareNextEvent();
                if (crisisPrepared)
                {
                    ResetSavedByHero();
                    DisplayNextEvent();
                }
            }

            if (GlobalEventHappened) //|| savedByHero
            {
                PeacefulYear = true; //After the global event happends let players play a round with no crisis to prep for.
                //needToNotifyPlayersNewEvent = false;
                BoltConsole.Write("Starting Peaceful year");
            }
        }
        state.CurrentSpellcasterTurn = turnOrder[turn_i];
        return(turnOrder[turn_i]);
    }
    public NetworkError(string name, string cause, string tip)
    {
        this.Name  = name;
        this.Cause = cause;
        this.Tip   = tip;

        UnityEngine.Debug.LogError("Error: " + name + " - " + cause + " - " + tip);
        BoltConsole.Write("Error: " + name + " - " + cause + " - " + tip, UnityEngine.Color.red);
    }
Example #5
0
    private void OnSceneLoadedLocally(string scene)
    {
        BoltConsole.Write("OnSceneLoadedLocally", Color.yellow);

        if (scene == "Debug")
        {
            BoltNetwork.Instantiate(player);
        }
    }
Example #6
0
        /*Only the server recieves this event.
         * Similar to NextTurnEvent, but doesn't update the turn.
         * Used for network disconnection.
         * Sends the current spellcasterId.
         */
        public override void OnEvent(NotifyTurnEvent evnt)
        {
            BoltConsole.Write("SERVER: Recieved a Notify turn event");
            int currentSpellcaster = gameStateEntity.GetComponent <NetworkGameState>().getCurrentTurn();
            var nextTurnEvnt       = NextPlayerTurnEvent.Create(Bolt.GlobalTargets.Everyone);

            nextTurnEvnt.NextSpellcaster = currentSpellcaster;
            nextTurnEvnt.Send();
        }
Example #7
0
        private void Setup(string playerName, Color playerColor)
        {
            BoltConsole.Write("Setup BomberPlayer");

            if (entity.IsOwner)
            {
                state.Color = playerColor;
                state.Name  = playerName;
            }
        }
        public override void Connected(BoltConnection c)
        {
            BoltConsole.Write("Connected", Color.red);

            c.UserData = new Player();
            c.GetPlayer().connection = c;
            c.GetPlayer().name       = "CLIENT:" + c.RemoteEndPoint.Port;

            c.SetStreamBandwidth(1024 * 1024);
        }
Example #9
0
    private void PlayerConnected(BoltConnection connection)
    {
        BoltConsole.Write("PlayerConnected", Color.yellow);

        PlayerContainer PC = new PlayerContainer(Random.Range(1000000, 9999999).ToString(), connection);

        players.Add(PC);

        RebuildRosterList();
    }
Example #10
0
        public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
        {
            //base.ConnectRequest(endpoint, token);
            BoltConsole.Write("Connect request");
            ServerAcceptToken tok = new ServerAcceptToken();

            tok.playerIndex = BoltPhysicsCallbacks.numPlayers;
            BoltPhysicsCallbacks.numPlayers++;
            BoltNetwork.Accept(endpoint, tok);
        }
        public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
        {
            BoltConsole.Write("ConnectRequest", Color.red);

            if (token != null)
            {
                BoltConsole.Write("Token Received", Color.red);
            }

            BoltNetwork.Accept(endpoint);
        }
 public override void ControlGained()
 {
     BoltConsole.Write("ControlGained", Color.blue);
     try
     {
         SetupCharacterSelectionUI();
     }
     catch
     {
         //loading previous game.
     }
 }
 public override void SceneLoadRemoteDone(BoltConnection connection)
 {
     BoltConsole.Write("SceneLoadRemoteDone");
     base.SceneLoadRemoteDone(connection);
     //scene is loaded on the client, send him an event to create a test player with a specific onlineIndex
     if (BoltNetwork.isServer)
     {
         CreatePlayerEvent e = CreatePlayerEvent.Create(connection);
         e.onlineIndex = totalPlayers;
         totalPlayers++;
         e.Send();
     }
 }
    public static void RegisterServerToMaster()
    {
        try
        {
            BoltConsole.Write("Registering Lobby");

            BoltNetwork.SetHostInfo("Test Lobby" /*token.Name, token*/, null);
        }
        catch (System.Exception e)
        {
            string error = "Caught a System Exception when registering Server. Message: " + e.Message;
            OnNetworkingError(new NetworkError("Lobby Registration Failure", error, ":("));
        }
    }
Example #15
0
        public override void EntityAttached(BoltEntity entity)
        {
            BoltConsole.Write("EntityAttached");

            if (!entity.isControlled)
            {
                LobbyPhotonPlayer photonPlayer = entity.gameObject.GetComponent <LobbyPhotonPlayer>();

                if (photonPlayer != null)
                {
                    photonPlayer.SetupOtherPlayer();
                }
            }
        }
Example #16
0
    public void Shoot()
    {
        Vector3    aimPoint;
        RaycastHit rayHit;

        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out rayHit, gunRange))
        {
            aimPoint = rayHit.point;
            var targetEntity = rayHit.collider.gameObject.GetComponent <BoltEntity>();
            if (entity.IsOwner)
            {
                BoltConsole.Write("HIT DETECTED  on OBJECT : " + rayHit.collider.gameObject.name);
                if (targetEntity != null)
                {
                    if (entity.IsAttached)
                    {
                        BoltConsole.Write("CALLING EVENT");
                        var evnt = TakeDamageEvent.Create(targetEntity.Source);
                        evnt.Damage = gunDamage;
                        evnt.Send();
                    }
                }
                if (projectileHitPrefab != null)
                {
                    Quaternion rot   = Quaternion.FromToRotation(Vector3.up, aimPoint);
                    var        hitfx = Instantiate(projectileHitPrefab, aimPoint, rot);
                }
            }
        }
        else
        {
            aimPoint = cam.transform.position + cam.transform.forward * gunRange;
        }
        if (entity.IsOwner)
        {
            muzzleIndex = state.WeaponActiveIndex;
            var muz = firePoints[muzzleIndex];

            var bullet = BoltNetwork.Instantiate(BoltPrefabs.Projectile, muz.transform.position, Quaternion.identity);

            bullet.transform.LookAt(aimPoint);

            if (muzzlePrefab != null)
            {
                var muzzleVfx = BoltNetwork.Instantiate(muzzlePrefab, muz.transform.position, Quaternion.identity);
                muzzleVfx.transform.forward = bullet.transform.forward;
            }
        }
    }
Example #17
0
    private void PlayerDisconnected(BoltConnection connection)
    {
        BoltConsole.Write("PlayerDisconnected", Color.yellow);

        PlayerContainer PC = players.First(x => x.Connection == connection);

        PC.InGame = false;

        if (PC.HasPlayer)
        {
            BoltNetwork.Destroy(PC.Player);
        }

        RebuildRosterList();
    }
Example #18
0
        public override void Connected(BoltConnection connection)
        {
            if (BoltNetwork.IsClient)
            {
                BoltConsole.Write(string.Format("Connected Client: {0}", connection), Color.blue);
                ClientConnectedUIHandler();
            }
            else if (BoltNetwork.IsServer)
            {
                BoltConsole.Write(string.Format("Connected Server: {0}", connection), Color.blue);

                var entity = BoltNetwork.Instantiate(BoltPrefabs.PlayerInfo);
                entity.AssignControl(connection);
            }
        }
Example #19
0
    public void TakeDamage(float amount)
    {
        BoltConsole.Write("Healt: " + health);
        health -= amount;

        healthbar.SetHealth(health);

        BoltConsole.Write("Healt after: " + health);


        if (health <= 0)
        {
            Die();
        }
    }
 public override void SceneLoadLocalDone(string map)
 {
     base.SceneLoadLocalDone(map);
     DLog.Log("Scene Load Local Done");
     BoltConsole.Write("SceneLoadLocalDone");
     //create bubble controller on every connection
     if (BoltNetwork.isServer)
     {
         BoltNetwork.Instantiate(BoltPrefabs.NetworkedBubbleController, new OnlineIndexToken()
         {
             onlineIndex = 0
         });
         totalPlayers++;
     }
 }
Example #21
0
        public override void Connected(BoltConnection connection)
        {
            base.Connected(connection);
            int assignedIndex = (connection.AcceptToken as ServerAcceptToken).playerIndex;

            if (!BoltPhysicsCallbacks.assigned)
            {
                BoltPhysicsCallbacks.assigned = true;
                BoltPhysicsCallbacks.me       = assignedIndex;
            }


            BoltConsole.Write("Connected---:  + assigned:  " + assignedIndex);
            Debug.Log("Connected");
        }
Example #22
0
 // Let's players know who countered the crisis
 public override void OnEvent(LetEveryoneKnowAboutCounter evnt)
 {
     if (playerSpellcaster.classType == evnt.Savior)
     {
         BoltConsole.Write("You saved the world with your spell!");
         BoltConsole.Write("You saved the world with your spell!");
         PanelHolder.instance.displayNotify("Congratulations", "You saved the world with your spell!", "OK");
     }
     else
     {
         BoltConsole.Write(evnt.Savior + " saved the world!");
         BoltConsole.Write(evnt.Savior + " saved the world!");
         PanelHolder.instance.displayNotify("Congratulations", evnt.Savior + " saved the world!", "OK");
     }
 }
Example #23
0
        // Commands

        public void SetupOtherPlayer()
        {
            BoltConsole.Write("SetupOtherPlayer", Color.green);

            nameInput.interactable = false;

            removePlayerButton.gameObject.SetActive(BoltNetwork.IsServer);
            removePlayerButton.interactable = BoltNetwork.IsServer;

            ChangeReadyButtonColor(NotReadyColor);

            readyButton.transform.GetChild(0).GetComponent <Text>().text = "...";
            readyButton.interactable = false;

            OnClientReady(state.Ready);
        }
Example #24
0
    public void JoinSlayers()
    {
        Debug.Log("Selecting team slayer");

        if (!PlayerPrefs.GetString("team").Equals("slayer"))
        {
            var spawnPosition = new Vector3(Random.Range(-5f, 5f), Random.Range(15f, 30f), 0f);
            BoltConsole.Write("Selecting team slayer");
            PlayerPrefs.SetString("team", "slayer");
            BoltNetwork.Destroy(gameObject);
            var playerCam = BoltNetwork.Instantiate(BoltPrefabs.Slayer, spawnPosition, Quaternion.identity);
        }
        else
        {
            BoltConsole.Write("already team slayer");
        }
    }
Example #25
0
        public override void BoltStartDone()
        {
            BoltConsole.Write("BoltStartDone breh");
            if (!BoltNetwork.IsRunning)
            {
                return;
            }

            if (BoltNetwork.IsServer)
            {
                RoomProtocolToken token = new RoomProtocolToken()
                {
                    ArbitraryData = "My DATA",
                };

                BoltLog.Info("Starting Server");
                // Start Photon Room
                BoltNetwork.SetServerInfo(_matchName, token);
                //BoltNetwork.EnableLanBroadcast();
                // Setup Host
                infoPanel.gameObject.SetActive(false);
                //PanelHolder.instance.hideConnectingPanel();
                ChangeTo(lobbyPanel);

                backDelegate = Stop;
                SetServerInfo("Host", "");
                connection_spellcaster = new Dictionary <string, int>();
                //SoundManager.instance.musicSource.Play();

                // Build Server Entity

                characterSelection = BoltNetwork.Instantiate(BoltPrefabs.CharacterSelectionEntity);
                characterSelection.TakeControl();

                gameStateEntity = BoltNetwork.Instantiate(BoltPrefabs.GameState);
                gameStateEntity.TakeControl();
                gameStateEntity.GetComponent <NetworkGameState>().onCreateRoom(_matchName);

                numPlayersInfo.text = gameStateEntity.GetComponent <NetworkGameState>().onPlayerJoined() + "";
            }
            else if (BoltNetwork.IsClient)
            {
                backDelegate = Stop;
                SetServerInfo("Client", "");
            }
        }
Example #26
0
        void Start()
        {
            s_Singleton  = this;
            currentPanel = mainMenuPanel;

            backButton.gameObject.SetActive(false);
            GetComponent <Canvas>().enabled = true;

            Instantiate(crisisHandler);

            DontDestroyOnLoad(gameObject);

            SetServerInfo("Offline", "None");

            BoltConsole.Write("Lobby Scene: " + lobbyScene.SimpleSceneName);
            BoltConsole.Write("Game Scene: " + gameScene.SimpleSceneName);

            SoundManager.instance.musicSource.Play();
        }
Example #27
0
 public void GlobalEventCounter(int evntID, bool isCountered)
 {
     if (isCountered)
     {
         // Give players feedback that their spellCaster friend saved them.
         Debug.Log("Global event is countered by:" + counterSpellcasterClass);
         BoltConsole.Write("Global event is countered by:" + counterSpellcasterClass);
         NetworkManager.s_Singleton.LetEveryoneKnowCountered(counterSpellcasterClass);
     }
     else
     {
         switch (evntID)
         {
         case 2:
             dealPercentDamageToAllSpellcasters(0.5f, "Tsunami");
             break;
         }
     }
 }
 // call this when crisis arrives (if roundsUntilCrisis == 0)
 public void FinishTsunami()
 {
     BoltConsole.Write("Finish Tsunami, crisisSolved: " + crisisSolved);
     if (crisisSolved)
     {
         SoundManager.instance.PlaySingle(SoundManager.crisisAverted);
         PanelHolder.instance.displayBoardScan("Tsunami Averted", "Out of gratitude for saving the Empire, the Capital is rewarding each wizard with an A tier rune from their class.",
                                               GameObject.Find("RuneContainer").transform.Find(player.Spellcaster.classType + " A Rune").GetComponent <Image>().sprite, "MainPlayerScene");
     }
     else
     {
         SoundManager.instance.PlaySingle(SoundManager.crisisLost);
         PanelHolder.instance.displayNotify("Tsunami Disaster", "You weren't able to stop the tsunami in time. All wizards lost half HP. Towns will not be scannable next round.", "MainPlayerScene");
         player.Spellcaster.TakeDamage((int)player.Spellcaster.fCurrentHealth / 2);
         player.Spellcaster.tsunamiConsequence = true;                               // checked in CustomEventHandler.cs
         player.Spellcaster.tsunamiConsTurn    = player.Spellcaster.NumOfTurnsSoFar; // tsunami consequence deactivated after 1 turn has passed (endturnclick)
     }
     currentCrisis = "";
 }
Example #29
0
    public override void SceneLoadLocalDone(string map)
    {
        BoltConsole.Write("Spawn Player on map " + map, Color.yellow);
        BomberPlayerController.Spawn();

        if (BoltNetwork.isServer)
        {
            A2SManager.SetPlayerInfo(null, "Photon Server");

            A2SManager.UpdateServerInfo(
                gameName: "Bolt Simple Tutorial",
                serverName: "Photon Bolt Server",
                map: map,
                version: "1.0",
                serverType: ServerType.Listen,
                visibility: Visibility.PUBLIC
                );
        }
    }
Example #30
0
        public override void SceneLoadLocalDone(string scene)
        {
            BoltConsole.Write("New scene: " + scene, Color.yellow);
            BoltConsole.Write("Spawned : " + spawned, Color.yellow);
            try
            {
                if (lobbyScene.SimpleSceneName == scene)
                {
                    ChangeTo(mainMenuPanel);
                    topPanel.isInGame = false;
                }
                else if (gameScene.SimpleSceneName == scene)
                {
                    if (BoltNetwork.IsServer)
                    {
                        //SpellCasterLobbyChoose sl = GameObject.find
                        //BoltNetwork.Detach(characterSelection);
                    }
                    //ChangeTo(null);

                    backDelegate      = Stop;
                    topPanel.isInGame = true;
                    topPanel.ToggleVisibility(false);
                    bookShelf.SetActive(false);
                    // Spawn Player
                    if (!spawned)
                    {
                        spawned = true;
                        SpawnGamePlayer();
                        MainPageHandler.instance.setupMainPage();
                    }

                    // SoundManager.instance.PlayGameBCM(SoundManager.gameBCG);
                }
            }
            catch (Exception e)
            {
                //BoltConsole.Write(e.Message, Color.red);
                //BoltConsole.Write(e.Source, Color.red);
                //BoltConsole.Write(e.StackTrace, Color.red);
            }
        }
Example #31
0
    public void TakeDamage(float amount)
    {
        if (entity.IsOwner)
        {
            BoltConsole.Write("---HIT DETECTED---: " + amount + " damage taken");

            BoltConsole.Write("Health: " + health);
            health -= amount;

            healthbar.SetHealth(health);

            BoltConsole.Write("Health after: " + health);


            if (health <= 0)
            {
                Die();
            }
        }
    }