Ejemplo n.º 1
0
        public void IsGameStarted(int gameId)
        {
            GameManager gameManager = new GameManager();

            lock (_syncRoot)
            {
                GameLogicManager gameLogic = new GameLogicManager();

                var game = EntityStateManager.CurrentGames.FirstOrDefault(x => x.GameId == gameId);
                if ((game != null && !game.IsPlayerAIAvailable && game.Players.Count == game.PlayersCount) || (game != null && game.IsPlayerAIAvailable && game.Players.Count == (game.PlayersCount + 1)))
                {
                    game = gameManager.StartGame(game.GameId);
                    if (game != null)
                    {
                        var gameObj = EntityStateManager.CurrentGames.FirstOrDefault(x => x.GameId == game.GameId);
                        gameObj.IsStarted = true;
                        Clients.Group(game.GameCode).allPlayersConnected();

                        // SET UP GAME DATA
                        var sectors = gameLogic.GetSectors();
                        Clients.Group(game.GameCode).setUpSectors(sectors);

                        gameObj.GameDetail = gameLogic.GetGameData(gameObj.GameId);
                        Clients.Group(game.GameCode).setUpGameData(gameObj.GameDetail);
                        Clients.Group(game.GameCode).gameStarted(game);

                        SetupGame(gameObj.GameId);
                    }
                    else
                    {
                        // Need to be implemented
                    }
                }
            }
        }
Ejemplo n.º 2
0
    public void ExecuteAttack(CharacterManager attacker, CharacterManager defender)
    {
        if (!defender.isDead())
        {
            double damage = GameLogicManager.CalculateDamage(attacker, defender);
            defender.ApplyDamage(damage);

            // check abilities that trigger on attack
            AbilityManager.CheckTriggeredAbilitiesActivation(TriggeredTriggerType.OnInflictedAttack, attacker, defender);
            AbilityManager.CheckTriggeredAbilitiesActivation(TriggeredTriggerType.OnReceivedAttack, defender, attacker);

            if (defender.isDead())
            {
                // check abilities that trigger on death
                AbilityManager.CheckTriggeredAbilitiesActivation(TriggeredTriggerType.OnKill, attacker, defender);
                AbilityManager.CheckTriggeredAbilitiesActivation(TriggeredTriggerType.OnDeath, defender, attacker);

                // check again in case of resurrection
                if (defender.isDead())
                {
                    Kill(defender);
                }
            }

            if (defender.gameObject.CompareTag("Player"))
            {
                UpdateHealthBar();
            }
        }
    }
Ejemplo n.º 3
0
 public StatManager(GameLogicManager gameLogicManager)
 {
     _gameLogicManager = gameLogicManager;
     _gameLogicManager.ScorePuckEvent += OnScorePuckEvent;
     _gameLogicManager.ShootPuckEvent += OnShootPuckEvent;
     _gameLogicManager.SavePuckEvent  += OnSavePuckEvent;
 }
Ejemplo n.º 4
0
 private void SetInitialReferences()
 {
     audioSource      = GetComponent <AudioSource>();
     gameLogicManager = GameObject.FindGameObjectWithTag("GameLogicManager").GetComponent <GameLogicManager>();
     score            = 0;
     UpdateUI();
 }
Ejemplo n.º 5
0
    public GameObject heldBox; //reference to the box you are holding right now


    // Use this for initialization
    void Start()
    {
        //find the box placeholder object/position
        boxHolder = GameObject.Find("BoxHolder");
        //reference the GameLogicManager script attached the GameLogicManager Object
        gameLogicx = GameObject.Find("GameLogicManager").GetComponent <GameLogicManager>();
    }
 void Start()
 {
     //初始化
     Initial();
     //遊戲邏輯
     gameLogicManager    = GameLogicManager.Instance;
     gameLogicManager.GM = this;
 }
Ejemplo n.º 7
0
 public TouchPoint(Vector2 initialPosition)
 {
     _gameLogicManager         = UnityEngine.Object.FindObjectOfType <GameLogicManager>();
     _currentDistanceFromStart = 0;
     _startPosition            = initialPosition;
     _rectTransform            = _gameLogicManager.CreatePointer();
     ChangePointerPosition(initialPosition);
 }
Ejemplo n.º 8
0
 private void initializeNewGame()
 {
     CurrentPlayer = PlayerOneInfo;
     GameLogicManager.GameState = eGameState.Active;
     GameLogicManager.InitializeRound();
     resetTicTacToeButtons();
     updateLabelsScores();
 }
Ejemplo n.º 9
0
 //-----------------------------------------------
 //  STATIC METHODS
 //-----------------------------------------------
 public static void CreateManager()
 {
     if (instance == null)
     {
         instance = new GameLogicManager();
         Instance.Initialize();
     }
 }
Ejemplo n.º 10
0
 override protected void Awake()
 {
     base.Awake();
     gameLogicManager = FindObjectOfType <GameLogicManager>();
     character        = GetComponent <TransformingRobotCharacter>();
     userController   = GetComponent <TransformingRobotUserController>();
     cameraController = GetComponentInChildren <CameraController>();
     bulletSpawner    = GetComponentInChildren <BulletSpawner>();
 }
Ejemplo n.º 11
0
    public void OnYes()
    {
        //Load chara in GameManager
        StartOptions startOptions    = GameObject.Find("Menu UI").GetComponent <StartOptions>();
        Character    curentCharacter = characterPool[currentCharacterId];

        GameLogicManager.SetCurrentCharacter(curentCharacter);
        startOptions.Fade(2);
    }
Ejemplo n.º 12
0
        public override void TakeDamage(Pointer pointer, Vector2 point)
        {
            var decreased = (int)Mathf.Round(AbsorbtionPercent * pointer.GetDamage() / 100);

            if (decreased > 0)
            {
                pointer.DecreaseDamage(decreased);
                GameLogicManager.CreateFloatingText("blocked", point - new Vector2(300, 0), new Color(0, 1, 0));
            }
        }
Ejemplo n.º 13
0
    // Use this for initialization
    void Start()
    {
        ui = GameObject.Find("UI").GetComponent <UIManager> ();

        timeSinceLastSync = 0;

        gameLogic = GameObject.Find("GameLogicManager").GetComponent <GameLogicManager> ();

        serverHealth = gameLogic.gameHP;
        clientHealth = gameLogic.gameHP;

        if (isLocalPlayer && hasAuthority)
        {
            gameLogic.isServer     = isServer;
            gameLogic.ourGamestate = this;
        }
        if (!isLocalPlayer)
        {
            gameLogic.theirGamestate = this;
        }

        if (hasAuthority)
        {
            // Client and Server game setup
            ui.multiPlayerQuickPlayStartGame();
            ui.multiPlayerQuickPlayWaitForGame();
        }

        if (!isServer && hasAuthority)
        {
            // Client proceeds to match immediately
            ui.proceedToMultiplayerGame();
        }

        gameStarted = false;

        // Server initially holds all object authority
        clientShieldAuthority = false;
        clientSwordAuthority  = false;
        clientStarAuthority   = false;

        sword  = ui.objects [0];
        shield = ui.objects [1];
        star   = ui.objects [2];

        shieldPos = shield.GetComponent <Transform> ().position;
        swordPos  = sword.GetComponent <Transform> ().position;
        starPos   = star.GetComponent <Transform> ().position;

        clientAnswerTime    = gameLogic.secondsPerRound;
        serverAnswerTime    = gameLogic.secondsPerRound;
        clientAnswerCorrect = false;
        serverAnswerCorrect = false;
    }
 private void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
     else
     {
         Debug.LogError(" Duplicate GameLogicManager");
     }
 }
Ejemplo n.º 15
0
 // Use this for initialization
 void Awake()
 {
     Application.targetFrameRate = 60;
     if (singletonInstance != null)
     {
         Debug.LogError("Multiple GameLogicManager instances");
         gameObject.SetActive(false);
         return;
     }
     singletonInstance = this;
 }
Ejemplo n.º 16
0
        private void togglePlayers()
        {
            CurrentPlayer = getNextPlayer();
            GameLogicManager.FirstPlayerTurn = !GameLogicManager.FirstPlayerTurn;

            if (CurrentPlayer.PlayerName == ComputerName)
            {
                labelPlayer2N.Font = new Font(this.Font, FontStyle.Bold);
                GameLogicManager.MakeMoveAsCPU();
                DrawLabelsBoldAndRegularRespectively(labelPlayer1N, labelPlayer2N);
            }
        }
Ejemplo n.º 17
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     EventManager.RegistAction(Events.ReStartGame, this.OnReStartGame);
     EventManager.RegistAction(Events.StartGame, this.OnStartGame);
     EventManager.RegistAction(Events.AddTowerGoFinish, this.OnAddTowerGoFinish);
     EventManager.RegistAction(Events.SceneTouched, this.OnSceneTouched);
     EventManager.RegistAction(Events.BackMain, this.OnBackToMain);
 }
Ejemplo n.º 18
0
        public TicTacToeGameForm(string i_PlayerOneName, string i_PlayerTwoName, int i_Size, eGameMode i_GameMode)
        {
            InitializeComponent();
            r_PlayerOne        = new Player(eCellValue.X, i_PlayerOneName);
            r_PlayerTwo        = new Player(eCellValue.O, i_PlayerTwoName);
            r_TicTacToeManager = new GameLogicManager(i_Size, i_GameMode, PlayerOneInfo, PlayerTwoInfo);

            r_TicTacToeManager.OnLogicBoardChanged += r_TicTacToe_OnGUIBoardChange;

            buildGUIBoard(i_Size);
            setLabelsPlayerNames();
            initializeNewGame();
        }
Ejemplo n.º 19
0
        public void Initialize()
        {
            m_CoroutineManager   = new CoroutineManager();
            m_ResourceLoader     = new ResourceLoader();
            m_FrameBuffer        = new FrameBuffer();
            m_FrameDataCollector = new FrameDataCollector();
            m_InputManager       = new InputManager();
            m_GameLogicManager   = new GameLogicManager();
            m_LevelManager       = new LevelManager();
            m_CameraManager      = new CameraManager();

            Utils.Random.seed = 1;
            m_LevelManager.Start();
        }
Ejemplo n.º 20
0
    private void Awake()
    {
        TGSDK.Initialize();
        TGSDK.PreloadAd();
        TGSDK.AdRewardSuccessCallback = OnAdRewardSuccess;
        TGSDK.AdRewardFailedCallback  = OnAdRewardFailed;
        Instance = this;

        CreatePlayer();

        _player         = GameObject.FindGameObjectWithTag(_Data._tagPlayer);
        _playerCollider = _player.GetComponent <CapsuleCollider>();
        _playerMovement = _player.GetComponent <PlayerMovement>();
        InitialPlayer();
    }
Ejemplo n.º 21
0
    private void Awake()
    {
        timeManager      = FindObjectOfType <TimeManager>();
        playerManager    = FindObjectOfType <PlayerManager>();
        gameLogicManager = FindObjectOfType <GameLogicManager>();
        mainBtnText      = FindObjectOfType <MainShootButton>().GetComponentInChildren <Text>();
        secondBtnText    = FindObjectOfType <SecondShootButton>().GetComponentInChildren <Text>();
        sssBtnText       = FindObjectOfType <SSSButton>().GetComponentInChildren <Text>();

        // 保证最开始低于CD的几秒钟时间计算正确
        foreach (var cdInfo in cdInfoList)
        {
            cdInfo.timeStamp = -cdInfo.cd;
        }
    }
Ejemplo n.º 22
0
    public TriviaRound(float secondsPerRound, Question question, string[] responses, string correctResponse, int roundNumber)
    {
        gameLogic = GameObject.Find("GameLogicManager").GetComponent <GameLogicManager> ();

        roundTime       = secondsPerRound;
        currentQuestion = question;
        answers         = responses;
        correctAnswer   = correctResponse;
        round           = roundNumber;

        /*
         *  answerTime == roundTime means the player took the entire round to respond
         *  I.e. the player didn't answer in time
         */
        answerTime = roundTime;
    }
Ejemplo n.º 23
0
        private static void Main()
        {
            gameLogic = GameLogicManager.GetOne();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            s_form = new Form1();

            // set up network
            NetPeerConfiguration config = new NetPeerConfiguration("chat");

            config.MaximumConnections = MaximumConnections;
            config.Port = Port;
            s_server    = new NetServer(config);

            Application.Idle += new EventHandler(Application_Idle);
            Application.Run(s_form);
        }
Ejemplo n.º 24
0
    void OnMouseDown()
    {
        GameLogicManager gameLogic = GlobalSettings.Instance.GameLogicManager.GetComponent <GameLogicManager>();

        if (gameLogic.CurrentState == GameState.DISTRIBUTION_CARD)
        {
            gameLogic.AddCardToPlayer(this.gameObject);
            gameLogic.UpdatePlayerCardPostion();
        }
        else if (gameLogic.CurrentState == GameState.BATTLE)
        {
            if (!gameLogic.IsCardBattle(this.gameObject) && !gameLogic.IsFighting() && !gameLogic.IsEmptyBattle())
            {
                gameLogic.MovePlayerCardToBattlePoint(this.gameObject);
                gameLogic.UpdatePlayerCardPostion();
            }
        }
    }
Ejemplo n.º 25
0
        private void CellButton_Click(object i_Sender, EventArgs i_EventArgs)
        {
            TicTacToeCellButton ticTacToeCellButton = i_Sender as TicTacToeCellButton;

            if (CurrentPlayer.PlayerName == PlayerOneInfo.PlayerName)
            {
                DrawLabelsBoldAndRegularRespectively(labelPlayer2N, labelPlayer1N);
            }
            else
            {
                DrawLabelsBoldAndRegularRespectively(labelPlayer1N, labelPlayer2N);
            }

            if (ticTacToeCellButton != null)
            {
                GameLogicManager.PlayerMove(ticTacToeCellButton.CellLocation);
            }
        }
Ejemplo n.º 26
0
        public void Start(GameParam param)
        {
            GameLogicManager gameManager = GameLogicManager.Instance;

            gameManager.CreateGame(param);
            gameManager.onPlayerDie       += OnPlayerDie;
            gameManager.onPlayerArriveEnd += OnPlayerArriveEnd;
            m_context = gameManager.Context;

            // 初始玩家数据
            InitPalyerData();

            InitGameInput();

            // 监听frame输入
            MonoHelper.AddUpdateListener(UpdateGame);

            GameCamera.FocusPlayerId = m_mainPlayerId;
        }
Ejemplo n.º 27
0
        public void OnTriggerEnter(Collider other)
        {
            if (!GameTagDefine.PLAYER.Equals(other.tag))
            {
                return;
            }
            GameLogicManager gameManager = GameLogicManager.Instance;
            GameMode         gameMode    = gameManager.GameMode;

            if (gameMode == GameMode.EndlessPVE || gameMode == GameMode.NormalPVE || gameMode == GameMode.TimelimitPVE)
            {
                PveModule pveModule = ModuleAPI.PveModule;
                pveModule.IncreaseScore(Score);
                pveModule.IncreasePuzzle(PuzzleCount);
            }

            // 设置为隐藏
            this.gameObject.SetActive(false);
        }
Ejemplo n.º 28
0
        public void GetPlayerStocks(int gameId, int playerId)
        {
            GameLogicManager gameLogic = new GameLogicManager();

            lock (_syncRoot)
            {
                var game         = EntityStateManager.CurrentGames.FirstOrDefault(x => x.GameId == gameId);
                var player       = game.Players.FirstOrDefault(x => x.PlayerId == playerId);
                var playerStocks = player.PlayerStocks.ToList();
                foreach (var temp in playerStocks)
                {
                    temp.CurrentPrice = gameLogic.GetStockValue(gameId, temp.SectorId, temp.StockId);
                    temp.IsIncreased  = (temp.CurrentPrice > temp.BoughtPrice) ? true : false;
                    temp.Percentage   = ((temp.CurrentPrice - temp.BoughtPrice) / temp.BoughtPrice) * 100;
                    temp.Profit       = (temp.CurrentPrice * temp.Quantity) - (temp.BoughtPrice * temp.Quantity);
                }
                Clients.Client(player.ConnectionId).loadPlayerStocksList(playerStocks);
            }
        }
Ejemplo n.º 29
0
        private IEnumerator Tick()
        {
            yield return(new WaitForSeconds(1));

            CurrentSeconds -= 1;
            RenderTime();
            if (CurrentSeconds > 0)
            {
                _counting = StartCoroutine(Tick());
            }
            else
            {
                _inProgress = false;
                if (!IsIntro)
                {
                    GameLogicManager.GameEnd();
                }
            }
        }
Ejemplo n.º 30
0
    private async Task SendServerRequest()
    {
        try
        {
            GameLogicManager logicManager = GameLogicManager.instance;
            string[]         allThreats   = new string[] {
                logicManager.threat1.GetValue().ToString(),
                             logicManager.threat2.GetValue().ToString(),
                             logicManager.threat3.GetValue().ToString(),
                             logicManager.threat4.GetValue().ToString(),
                             logicManager.threat5.GetValue().ToString(),
                             logicManager.threat6.GetValue().ToString()
            };
            string threatString = "";
            for (int i = 0; i < allThreats.Length; i++)
            {
                threatString = threatString + allThreats[i];
                if (i < allThreats.Length - 1)
                {
                    threatString = threatString + ", ";
                }
            }

            string playerId = logicManager.MyPlayerId;

            Debug.Log(threatString);
            Debug.Log(playerId);
            if (!string.IsNullOrEmpty(threatString) && !string.IsNullOrEmpty(playerId))
            {
                Debug.Log("Sending Create Room Request");
                var  serverApi          = ServerApi.Instance;
                Room createRoomResponse = await serverApi.CreateRoomAsync(playerId, threatString, 5, 30L, 1000, null);

                Debug.Log($"{nameof(createRoomResponse)}:{createRoomResponse.ToJson()}");
                GameLogicManager.instance.UpdateGameState(null, createRoomResponse);
            }
        }
        catch (Exception e)
        {
            UnityEngine.Debug.LogException(e);
        }
    }
Ejemplo n.º 31
0
 // Use this for initialization
 void Start()
 {
     if (isServer)
     {
         gameLogicManager = GameObject.Find("GameManager").GetComponent <GameLogicManager>();
         playerId         = 0;
     }
     else
     {
         playerId = 1;
     }
     if (isLocalPlayer)
     {
         GameObject[] spinAnchorList = GameObject.FindGameObjectsWithTag("SpinAnchor");
         foreach (GameObject spinAnchor in spinAnchorList)
         {
             spinAnchor.GetComponent <AnchorLogic>().givePlayerControllerReference(this);
         }
     }
 }