void Awake() {
     UnityUtility.ValidateComponentPresence<BoxCollider>(gameObject);
     _transform = transform;
     _renderer = gameObject.GetComponentInChildren<MeshRenderer>();
     _eventMgr = GameEventManager.Instance;
     _systemMgr = gameObject.GetSafeFirstMonoBehaviourInParents<SystemCreator>();
 }
Esempio n. 2
0
 protected override void Awake() {
     base.Awake();
     if (!_isStaticHudPublisherFieldsInitialized) {
         InitializeStaticHudPublisherFields();
     }
     _eventMgr = GameEventManager.Instance;
 }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        m_CurrentHealth = m_MaxHealth;

        m_MaxScale = m_HealthBar.transform.localScale.x;

        m_GameEventManager = FindObjectOfType<GameEventManager>();
    }
Esempio n. 4
0
 protected override void Awake() {
     base.Awake();
     _orbitalPlane = gameObject.GetSafeFirstMonoBehaviourInChildren<OrbitalPlaneInputEventRouter>();
     _systemGraphics = gameObject.GetSafeMonoBehaviour<SystemGraphics>();
     _star = gameObject.GetSafeFirstMonoBehaviourInChildren<Star>();
     _planetsAndMoons = gameObject.GetSafeMonoBehavioursInChildren<FollowableItem>();
     _eventMgr = GameEventManager.Instance;
     _selectionMgr = SelectionManager.Instance;
 }
Esempio n. 5
0
    // Use this for initialization
    void Start()
    {
        m_Source = gameObject.AddComponent<AudioSource>();

        m_Source.clip = m_AudioClips[(int) m_CurrentState];
        m_Source.loop = false;
        m_Source.Play();

        m_GameEventManager = FindObjectOfType<GameEventManager>();
    }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShipNavigator"/> class.
 /// </summary>
 /// <param name="t">Ship Transform</param>
 /// <param name="data">Ship data.</param>
 public ShipNavigator(Transform t, ShipData data) {
     _transform = t;
     _data = data;
     _rigidbody = t.rigidbody;
     _rigidbody.useGravity = false;
     _eventMgr = GameEventManager.Instance;
     _gameTime = GameTime.Instance;
     _gameStatus = GameStatus.Instance;
     _generalSettings = GeneralSettings.Instance;
     Subscribe();
     _gameSpeedMultiplier = _gameTime.GameSpeed.SpeedMultiplier();   // FIXME where/when to get initial GameSpeed before first GameSpeed change?
     _thrustHelper = new ThrustHelper(0F, 0F, _data.FullStlEnginePower);
 }
Esempio n. 7
0
 protected override void Awake() {
     base.Awake();
     enabled = false;    // disabled behaviours aren't updated
     _fleetCmd = gameObject.GetSafeFirstMonoBehaviourInChildren<FleetCommand>();
     _fleetCmdTransform = _fleetCmd.transform;
     _fleetGraphics = gameObject.GetSafeMonoBehaviour<FleetGraphics>();
     ShipCaptains = gameObject.GetSafeMonoBehavioursInChildren<ShipCaptain>().ToList();
     _gameMgr = GameManager.Instance;
     _eventMgr = GameEventManager.Instance;
     _selectionMgr = SelectionManager.Instance;
     InitializeFleetIcon();
     Subscribe();
 }
Esempio n. 8
0
    // Use this for initialization
    public override void OnStartClient()
    {
        singleton = this;

        //Debug.Log("started game event manager");
        base.OnStartClient();
        if (events == null)
        {
            events = new HashSet <GameEvent>();
        }
        if (countDownEvents == null)
        {
            countDownEvents = new List <GameEvent>();
        }
        namedEvents = new Dictionary <string, GameEvent>();
        singleton   = this;
        //StartCoroutine(setUpStartGame());
        setUpStartGame();
    }
Esempio n. 9
0
        internal void OnTurnStart(BasePlayer player)
        {
            if (player == this.Owner)
            {
                var minionsInHand = this.Owner.Hand.Where(card => card is BaseMinion).ToList();
                if (minionsInHand.Any())
                {
                    int randomMinionIndex = GameEngine.Random.Next(minionsInHand.Count());
                    var randomMinion      = minionsInHand[randomMinionIndex] as BaseMinion;

                    GameEngine.GameState.Board.RemoveCard(this);
                    player.AddCardToHand(this);
                    GameEventManager.UnregisterForEvents(this);

                    var firstEmptySlot = GameEngine.GameState.CurrentPlayerPlayZone.Count(card => card != null);
                    player.SummonMinion(randomMinion, null, firstEmptySlot, CardEffect.NONE, forceSummoned: true, cardSource: player.hand);
                }
            }
        }
Esempio n. 10
0
        protected override void HandleEvent(RenderWindow window, EventArgs args)
        {
            if (args is MouseButtonEventArgs mouseArgs)
            {
                Console.WriteLine($"{mouseArgs.X} {mouseArgs.Y}");

                var increment = 490f / board.BoardSize;
                var point     = Revert(new Point(Floor(mouseArgs.X / increment), Floor((mouseArgs.Y - 105) / increment)));

                Console.WriteLine($"Clicked on: {point.X} {point.Y}");

                if (shapeManager.ResetRectangle.Rectangle.ToFloatRect().Contains(mouseArgs.X, mouseArgs.Y))
                {
                    Console.WriteLine("Click on reset button");
                    shapeManager.ShouldUpdate = GameEventManager.ClickedOnReset();
                    return;
                }

                if (point.X < 0 || point.Y < 0)
                {
                    Console.WriteLine("Click outside of play area.");
                    return;
                }

                if (mouseArgs.Button == Mouse.Button.Left)
                {
                    if (board.Pristine)
                    {
                        GameStateGenerator.GenerateBoard(board, point);
                        board.Pristine  = false;
                        board.GameState = GameState.GameState.Running;
                    }

                    shapeManager.ShouldUpdate = GameEventManager.ClickedOnTile(point);
                }

                if (mouseArgs.Button == Mouse.Button.Right)
                {
                    shapeManager.ShouldUpdate = GameEventManager.FlagOnTile(point);
                }
            }
        }
Esempio n. 11
0
    void Update()
    {
        foreach (Touch touch in Input.touches)
        {
            if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled && jumpflag < 3)
            {
                rigidbody.AddForce(jumpVelocity, ForceMode.VelocityChange);
                touchingPlatform = false;
                jumpflag++;
            }
        }
        //  distanceTraveled = 0f;

        distanceTraveled = transform.localPosition.x;
        GUIManager.SetDistance(distanceTraveled);
        if (transform.localPosition.y < gameOverY)
        {
            GameEventManager.TriggerGameOver();
        }
    }
Esempio n. 12
0
        public override void UpdateState(Entity entity, GameTime gameTime)
        {
            var player = entity as Player;

            if (player.State.InTransition)
            {
                player.Animator.Play(AnimationDictionary.PlayerFall);
                player.State.InTransition = false;
            }
            else
            {
                if (FallAnimationStillPlaying(player))
                {
                    return;
                }

                Entity.Destroy(player);
                GameEventManager.Raise(new PlayerDied());
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Called when a minion is silenced
        /// </summary>
        public void Silence()
        {
            Logger.Instance.Debug(string.Format("Minion {0}[{1}] has been silenced!", this.Name, this.Id));

            // Unregister all event listeners, including death rattles
            GameEventManager.UnregisterForEvents(this);
            GameEngine.UnregisterDeathrattle(this);

            // Remove any effects but keep it exhausted if it was already
            bool wasExhausted = this.StatusEffects.HasFlag(MinionStatusEffects.EXHAUSTED);

            this.StatusEffects = MinionStatusEffects.SILENCED | (wasExhausted ? MinionStatusEffects.EXHAUSTED : 0);

            // Remove any bonus health
            this.CurrentHealth = Math.Min(this.MaxHealth - this.BonusHealth, this.CurrentHealth);

            // Reset the attack power to its original value
            this.PermanentAttackBuff = 0;
            this.TemporaryAttackBuff = 0;
        }
Esempio n. 14
0
    private void DecreaseLives()
    {
        if (gameActive)
        {
            currentLives -= 1;

            if (currentLives <= 0)
            {
                gameActive = false;

                GUIManager.SetLives(0);

                GameEventManager.TriggerGameOver();
            }
            else
            {
                GUIManager.SetLives(currentLives);
            }
        }
    }
Esempio n. 15
0
    /// <summary>
    /// Kill player, make invisible & invisible, spawn at spawn point, and create particles
    /// </summary>
    /// <param name="other"> Who are we colliding with?</param>
    public void KillPlayer(Collider other)
    {
        if (_state != State.Playing)
        {
            return;
        }

        // Call enemy's Explode function for particles / sfx
        if (other.CompareTag("Enemy"))
        {
            other.GetComponent <Enemy>().Explode();
        }

        // Subtract a life, and update the UI
        GameManager.lives--;
        GameEventManager.TriggerUpdateLives();

        // Set the player temporarily invincible, flash colors, and re-spawn at a new location
        StartCoroutine(OnBecameInvisible());
    }
Esempio n. 16
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.E) && playerIsNearby && _isFinished)
     {
         if (checkForRequiredResource != null)
         {
             checkForRequiredResource();
         }
         // player.MakeExchange(stuffNeeded, goldReward);
     }
     if (Input.GetKeyDown(KeyCode.L) && playerIsNearby)
     {
         GameEventManager.ExchangeForCurrency(Resource.WOOD, 6000, Resource.COIN, 6000);
     }
     if ((_requiredResource == Resource.WOOD || _requiredResource == Resource.COIN) && _questTarget == null && playerIsNearby)
     {
         _resourceText[0] = "Thanks. ";
         _resourceText[1] = " Please help my Brothers aswell.";
         text[0].text     = _resourceText [0] + _resourceText [1];
     }
 }
Esempio n. 17
0
 void ActiveFlashLight()
 {
     if (GameEventManager.canUseFlashLight)
     {
         if (Input.GetKeyDown(KeyCode.F))
         {
             if (!isFlashLightOpening)
             {
                 SoundManager.PlaySound(SoundManager.SoundEffects.FlashOn);
                 GameEventManager.IncreaseFlashLightUsedNumber();
                 isFlashLightOpening = true;
             }
             else
             {
                 SoundManager.PlaySound(SoundManager.SoundEffects.FlashOff);
                 isFlashLightOpening = false;
             }
         }
     }
     InGameAssetManager.i.flashLight.enabled = isFlashLightOpening;
 }
Esempio n. 18
0
    void Update()
    {
        if (!gameOver)
        {
            transform.Translate(3f * Time.deltaTime, 0f, 0f);
            if (((Input.GetKeyDown("space")) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)) && (transform.position.y < 5))
            {
                rigidbody.velocity = new Vector3(0, 4, 0);
                audio.PlayOneShot(flapSound, 0.7F);
            }
            if (transform.localPosition.y < -2)
            {
                gameOver = true;
                Reset();
                GameOver();
                GameEventManager.TriggerGameOver();
            }
        }

        distanceTraveled = transform.localPosition.x;
    }
Esempio n. 19
0
    void Update()
    {
        if (running)
        {
            runningFor   += Time.deltaTime;
            timeText.text = ((int)runningFor).ToString();
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                GameEventManager.TriggerGameStart();
            }

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Debug.Log("Quit called");
                Application.Quit();
            }
        }
    }
Esempio n. 20
0
    void Update()
    {
        if (Input.GetButtonDown("Jump"))
        {
        }
        distanceTraveled = transform.localPosition.x;
        score            = distanceTraveled + bonuses;
        GUIManager.SetDistance(score);

        if (transform.localPosition.y < gameOverY)
        {
            GameEventManager.TriggerGameOver();
        }

        bool test = Input.GetKeyDown(KeyCode.JoystickButton0);

        if (test)
        {
            Debug.Log("Get Key Working");
        }
    }
Esempio n. 21
0
    private IEnumerator InitEntityInternal()
    {
        GameObject avatarRootGo = new GameObject("avatar");

        avatarRoot = avatarRootGo.transform;
        avatarRoot.SetParent(transform);
        avatarRoot.ResetPRS();

        yield return(StartCoroutine(OnSetupAvatar()));

        foreach (var renender in Renderers)
        {
            renender.enabled = false;
        }

        OnSetupLayer();

        if (avatarModel != null)
        {
            animator = avatarModel.GetComponent <Animator>();
        }

        if (animator != null)
        {
            animator.cullingMode     = AnimatorCullingMode.CullCompletely;
            animator.applyRootMotion = false;
            yield return(StartCoroutine(OnSetupController()));
        }

        foreach (var renender in Renderers)
        {
            renender.enabled = true;
        }

        Ready = true;

        OnReady();

        GameEventManager.RaiseEvent(GameEventTypes.EntityCreated, this);
    }
Esempio n. 22
0
        /// <summary>
        /// Attacks another target
        /// </summary>
        /// <param name="target">The target to attack</param>
        public void Attack(IDamageableEntity target)
        {
            // Make sure the minion isn't exhausted first or can't attack
            if (!this.CanAttack)
            {
                throw new InvalidOperationException("This minion can't attack yet!");
            }

            // Make sure we're not attacking through a taunt
            var enemyPlayZone = GameEngine.GameState.WaitingPlayerPlayZone;
            var targetMinion  = target as BaseMinion;

            if (((targetMinion != null && !targetMinion.HasTaunt) || target is BasePlayer) &&
                enemyPlayZone.Any(minion => minion != null && ((BaseMinion)minion).HasTaunt))
            {
                throw new InvalidOperationException("Can't attack through taunt!");
            }

            if (targetMinion != null && targetMinion.IsStealthed)
            {
                throw new InvalidOperationException("Can't attack a minion that is stealthed!");
            }

            if (this.IsStealthed)
            {
                this.RemoveStatusEffects(MinionStatusEffects.STEALTHED);
            }

            this.attacksThisTurn++;

            // Fire attacking event
            bool shouldAbort;

            GameEventManager.Attacking(this, target, isRetaliation: false, shouldAbort: out shouldAbort);

            if (!this.HasWindfury || (this.HasWindfury && this.attacksThisTurn >= 2))
            {
                this.ApplyStatusEffects(MinionStatusEffects.EXHAUSTED);
            }
        }
Esempio n. 23
0
 // Update is called once per frame
 void Update()
 {
     source.transform.position = transform.position;
     //Debug.Log("Number things found: " + thingsFound);
     if (canGreet())
     {
         if (!source.isPlaying)
         {
             int mrvli = getMostRelevantVoiceLineIndex();
             if (mrvli >= 0)
             {
                 setVoiceLine(mrvli);
                 NPCVoiceLine npcvl = voiceLines[mrvli];
                 npcvl.played = true;
                 lastPlayedCheckPointLineIndex = mrvli;
                 if (npcvl.triggerEvent != null)
                 {
                     GameEventManager.addEvent(npcvl.triggerEvent);
                 }
             }
         }
     }
     else
     {
         if (shouldStop())
         {
             source.Stop();
         }
     }
     if (source.isPlaying)
     {
         string voicelinetext = voiceLines[currentVoiceLineIndex].getVoiceLineText(source.time);
         NPCManager.speakNPC(gameObject, true, voicelinetext);
     }
     else if (currentVoiceLineIndex >= 0)
     {
         currentVoiceLineIndex = -1;
         NPCManager.speakNPC(gameObject, false, "");
     }
 }
Esempio n. 24
0
    // Update is called once per frame
    void Update()
    {
        if (touchingPlatform && Input.GetButtonDown("Jump"))
        {
            rigidbody.AddForce(jumpVelocity, ForceMode.VelocityChange);
            touchingPlatform = false;
        }
        distanceTraveled = transform.localPosition.x;
        GUIManager.setDistance(distanceTraveled);

        if (transform.localPosition.y < gameOverY)
        {
            GameEventManager.TriggerGameOver();
        }
        float obstX = PlatformManager.getObstacleX();

        Debug.Log(obstX);
        if (distanceTraveled >= obstX - 1)
        {
            PlatformManager.removeObstacle(obstX);
        }
    }
        //=====================================================================================================================//
        //================================================ Unity Event Callbacks ==============================================//
        //=====================================================================================================================//

        #region Unity Event Callbacks

        protected void OnEnable()
        {
            if (string.IsNullOrEmpty(listenToEventID))
            {
                var result = GameEventManager.RegisterHandler(listenToEventID, OnEventRaised);

                if (verbose)
                {
                    Debug.Log(string.Format("GameEventBehaviour [{0}]: Handler Registration: {1}", name, (result ? "SUCCESS" : "FAILURE")), gameObject);
                }
            }

            if (listenToGameEvent != null)
            {
                var result = listenToGameEvent.RegisterMethod(OnEventRaised);

                if (verbose)
                {
                    Debug.Log(string.Format("GameEventBehaviour [{0}]: Method Registration: {1}", name, (result ? "SUCCESS" : "FAILURE")), gameObject);
                }
            }
        }
Esempio n. 26
0
    void Update()
    {
        if (readyToClose && prefab != null)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                DestroyStatusBox();
                if (PacketProcessor.isAuthenticated)
                {
                    if (statusBoxLink != null)
                    {
                        menuHandler.EnterMenu(statusBoxLink);
                    }
                }
                else if (menuHandler.GetActiveMenu() == menus[(int)Menus.LoginMenu] && PacketProcessor.loggedInSuccessfully)
                {
                    menuHandler.EnterMenu(statusBoxLink);
                    PacketProcessor.loggedInSuccessfully = false;
                }
                GameEventManager.TriggerStatusBoxClosed(new GameEventArgs {
                    StatusBoxClosed = true
                });
                readyToClose  = false;
                statusBoxLink = null;
            }
            if (Input.GetButtonDown("Fire2"))
            {
                DestroyStatusBox();
                readyToClose  = false;
                statusBoxLink = null;
            }
        }


        if (statusTextObj != null)
        {
            statusTextObj.text = "Status: " + statusText;
        }
    }
Esempio n. 27
0
    void AddObject()
    {
        nextPosition.x = objectList[objectList.Count - 1].localPosition.x + tileWidth;

        if (currentFloorLength >= setFloorLength)
        {
            var gap = (int)Random.Range(MinGap.x, MaxGap.x);
            nextPosition.x += gap;

            setFloorLength     = Random.Range(MinFloorLength, MaxFloorLength);
            currentFloorLength = 1;

            UIManager.TempText = setFloorLength.ToString();
            GameEventManager.OnFloorMovement();
        }
        else
        {
            currentFloorLength++;
        }

        objectList.Add((Transform)Instantiate(Prefab, nextPosition, Quaternion.identity));
    }
Esempio n. 28
0
    // This should be called before any other gameobject awakes
    private void Awake ()
    {
        // Singleton pattern : this is the only case where it should be used
        if(ms_Instance == null)
        {
            ms_Instance = this;
            DontDestroyOnLoad (gameObject);
            
            // Keep the Updater first, as the other members might want to register to it
            m_Logger = new UnityLogger ();
            LoggerProxy.Open (m_Logger);
            m_Updater = new Updater ();
            UpdaterProxy.Open (m_Updater);
            m_GameEventManager = new GameEventManager ();
            GameEventManagerProxy.Open (m_GameEventManager);
            m_InputManager = new InputManager ();
            InputManagerProxy.Open (m_InputManager);
            m_LevelManager = new LevelManager ();
            LevelManagerProxy.Open (m_LevelManager);
            m_TileManager = new TileManager ();
            TileManagerProxy.Open (m_TileManager);
            m_CommandStack = new CommandStack ();
            CommandStackProxy.Open (m_CommandStack);
            m_GoalManager = new GoalManager ();
            GoalManagerProxy.Open (m_GoalManager);
            m_SoundManager = new SoundManager ();
            SoundManagerProxy.Open (m_SoundManager);
            m_SoundManager.SetMusicSource (m_MusicSource);
            m_SoundManager.SetFXSource (m_EfxSource);

            m_GameFlowHSM = new GameFlowHSM ();
            m_GameFlowHSM.Start (typeof (GameFlowMenuState));
        }
        else if (ms_Instance != this)
        {
            Destroy (gameObject);
            return;
        }
    }
Esempio n. 29
0
    // Update is called once per frame
    void Update()
    {
        gameTimer += Time.deltaTime;

        PlayerBoostControl();
        //SwapActive ();
        SwapAttack();

        if (isBossCreated)
        {
            if (bossObject == null)
            {
                if (!isStageUpgraded)
                {
                    isStageUpgraded = false;
                    NOW_STAGE      += 1;
                    isBossCreated   = false;
                    GameEventManager.AddNewEvent(EVENT_CHALLENGE_NEXT_STAGE);
                }
            }
        }
    }
Esempio n. 30
0
 void Update()
 {
     if (firstShow)
     {
         float dis = Vector3.Distance(startPoint, InGameAssetManager.i.player.transform.position);
         if (dis > distanceToShowRunUI)
         {
             AIO.sprintSpeed = runSpeed;
             UI_Movement.SetActive(false);
             UI_Run.SetActive(true);
             UI_Flashlight.SetActive(false);
         }
         else
         {
             AIO.sprintSpeed = AIO.walkSpeed;
         }
         if (GameEventManager.GetOpeningDoorNumbers() >= 1)
         {
             UI_Movement.SetActive(false);
             UI_Run.SetActive(false);
             UI_Flashlight.SetActive(true);
             GameEventManager.canUseFlashLight = true;
         }
         if (GameEventManager.GetFlashLightUsedNumbers() == 1)
         {
             UI_Movement.SetActive(false);
             UI_Run.SetActive(false);
             UI_Flashlight.SetActive(false);
             firstShow = false;
         }
     }
     else
     {
         UI_Movement.SetActive(false);
         UI_Run.SetActive(false);
         UI_Flashlight.SetActive(false);
         AIO.sprintSpeed = runSpeed;
     }
 }
Esempio n. 31
0
    // Update is called once per frame
    void Update()
    {
        UpdateTrail();
        UpdateMaterial();
        animations.SetInteger("state", (int)shape);

        UpdateLifes();

        if (lifes <= 0)
        {
            GameEventManager.TriggerGameOver();
        }

        float wantedDepth  = -(PlatformManager.depth * (int)trail) + offset.z;
        float currentDepth = transform.position.z;

        // Damp the Depth
        currentDepth = Mathf.Lerp(currentDepth, wantedDepth, DepthDamping * Time.deltaTime);

        // Set the z of the cat
        transform.position = new Vector3(transform.position.x, transform.position.y, currentDepth);
    }
Esempio n. 32
0
    void Start()
    {
        cm = FindObjectOfType <CharacterManager>();
        gm = FindObjectOfType <GameEventManager>();
        sm = FindObjectOfType <GameSceneManager>();
        gs = FindObjectOfType <GameState>();
        var obj = FindObjectsOfType <Canvas>();

        for (int i = 0; i < obj.Length; ++i)
        {
            if (obj[i].name == "Story")
            {
                canvas = obj[i];
                break;
            }
        }
        if (canvas == null)
        {
            Debug.Log("ERROR: No story canvas");
        }
        RemoveChildren();
        story = new Story(inkJSONAsset.text);
    }
Esempio n. 33
0
    protected override void InitManager()
    {
        defaultMixer = Resources.Load <AudioMixer>("System/AudioMixer");
        if (defaultMixer != null)
        {
            var audioGroupVals  = System.Enum.GetValues(typeof(AudioGroupTypes));
            var audioGroupNames = System.Enum.GetNames(typeof(AudioGroupTypes));
            for (int i = 0; i < audioGroupVals.Length; i++)
            {
                audioMixerGroups[(int)audioGroupVals.GetValue(i)] = defaultMixer.FindMatchingGroups((string)audioGroupNames.GetValue(i))[0];
            }
        }

        DestroyExistingListener();

        GameObject listenerGo = new GameObject("AudioListener");

        listenerGo.transform.parent = transform;
        listenerTrans = listenerGo.transform;
        listenerGo.AddComponent <AudioListener>();

        GameEventManager.RegisterEvent(GameEventTypes.EnterScene, OnEnterScene);
    }
Esempio n. 34
0
    void StateChange()
    {
        switch (m_eCurrentState)
        {
        case PlayerState.Spwan:
            break;

        case PlayerState.Init:
            Init();

            break;

        case PlayerState.Gameplay:
            starCnt.text = "" + Main.Instance.starsCnt;
            break;

        case PlayerState.Died:
            playerVisual.SetActive(false);
            Main.Instance.StopBGMusic();
            GameEventManager.TriggerGameOver();
            break;
        }
    }
Esempio n. 35
0
        public Game(int gameID, Player player1, Player player2, Deck player1Deck, Deck player2Deck)
        {
            GameCardManager = new GameCardManager();
            GameCardManager.BindGame(this);

            GameID      = gameID;
            GamePlayer1 = new GamePlayer(player1, new Hero(1, 30, 30), CreateGameDeck(1, player1Deck));
            GamePlayer1.BindGame(this);
            GamePlayer2 = new GamePlayer(player2, new Hero(2, 30, 30), CreateGameDeck(2, player2Deck));
            GamePlayer2.BindGame(this);
            RoundCount = 0;
            Random randomGenerator = new Random();

            if (randomGenerator.NextDouble() > 0.5)
            {
                CurrentGamePlayerID = 1;
                GamePlayer1.Draw(3);
                GamePlayer2.Draw(4);
            }
            else
            {
                CurrentGamePlayerID = 2;
                GamePlayer1.Draw(4);
                GamePlayer2.Draw(3);
            }
            Field1 = new Field(1);
            Field1.BindGame(this);
            Field2 = new Field(2);
            Field2.BindGame(this);

            AssemblyGamePlayerEvents(GamePlayer1);
            AssemblyGamePlayerEvents(GamePlayer2);
            AssemblyFieldEvents(Field1);
            AssemblyFieldEvents(Field2);

            EventManager = new GameEventManager(this);
        }
        protected void OnDisable()
        {
            if (!string.IsNullOrEmpty(listenToEventID))
            {
                var result = GameEventManager.UnregisterHandler(listenToEventID, OnEventRaised);

                if (verbose)
                {
                    Debug.Log(string.Format("GameEventBehaviour [{0}]: Handler Unregistration: {1}", name, (result ? "SUCCESS" : "FAILURE")), gameObject);
                }
            }
            else
            {
                if (verbose)
                {
                    Debug.LogWarning(string.Format("GameEventBehaviour [{0}]: GameEventID is null!", name), gameObject);
                }
            }

            if (listenToGameEvent != null)
            {
                var result = listenToGameEvent.UnregisterMethod(OnEventRaised);

                if (verbose)
                {
                    Debug.Log(string.Format("GameEventBehaviour [{0}]: Method Unregistration: {1}", name, (result ? "SUCCESS" : "FAILURE")), gameObject);
                }
            }
            else
            {
                if (verbose)
                {
                    Debug.LogWarning(string.Format("GameEventBehaviour [{0}]: GameEvent reference is null!", name), gameObject);
                }
            }
        }
Esempio n. 37
0
    private void SetupWorld(int width, int height, int depth)
    {
        Width  = width;
        Height = height;
        Depth  = depth;

        // Set the current world to be this world.
        Current = this;

        tiles = new Tile[Width, Height, Depth];

        // TODO: Do we need to do any cleanup of the old world?
        RoomManager           = new RoomManager();
        RoomManager.Adding   += (room) => roomGraph = null;
        RoomManager.Removing += (room) => roomGraph = null;

        FillTilesArray();

        FurnitureManager          = new FurnitureManager();
        FurnitureManager.Created += OnFurnitureCreated;

        UtilityManager   = new UtilityManager();
        CharacterManager = new CharacterManager();
        InventoryManager = new InventoryManager();
        jobManager       = new JobManager();
        GameEventManager = new GameEventManager();
        PowerNetwork     = new PowerNetwork();
        FluidNetwork     = new FluidNetwork();
        temperature      = new TemperatureDiffusion(this);
        ShipManager      = new ShipManager();
        Wallet           = new Wallet();
        CameraData       = new CameraData();

        LoadSkybox();
        AddEventListeners();
    }
 public AMortalFocusablePresenter(IViewable view)
     : base(view) {
     _eventMgr = GameEventManager.Instance;
 }
Esempio n. 39
0
 void Awake() {
     playerPrefsMgr = PlayerPrefsManager.Instance;
     eventMgr = GameEventManager.Instance;
 }
    void Start()
    {
        mainEventManager=this;
        //possibleEvents.Add (new EventChance(new FoodSpoilage(),0.04f));
        //possibleEvents.Add (new EventChance(new MonsterAttack(),0.04f));
        //Putting total probability space to >1 should work properly, as long as it is done as the first probability

        //possibleEvents.Add (new EventChance(new LostInAnomaly(),0.04f));
        /*
        possibleEvents.Add( new EventChance(new NewSurvivor(),0.04f));
        possibleEvents.Add( new EventChance(new MedicalCache(),0.04f));
        possibleEvents.Add (new EventChance(new SurvivorRescue(),0.04f));
        possibleEvents.Add(new EventChance(new SearchForSurvivor(),0.04f));
        */

        GameManager.GameOver+=ClearEventQueue;
        /*
        //Add highest first for proper rolling
        eventPossibilities.Add (0.16f,new LostInAnomaly());
        eventPossibilities.Add (0.12f,new CacheInAnomaly());
        eventPossibilities.Add (0.08f,new MonsterAttack());
        eventPossibilities.Add (0.04f,new FoodSpoilage());//0.04f, new FoodSpoilage());
        */
        //eventPossibilities.Add (0.05f,new NewSurvivor());
    }
Esempio n. 41
0
 ///<summary>
 /// Called once from the constructor, this does all required initialization
 /// </summary>
 private void Initialize() {
     // Warning! Instance is null until after this is complete!
     IncrementInstanceCounter();
     _eventMgr = GameEventManager.Instance;
     _playerPrefsMgr = PlayerPrefsManager.Instance;
 }
Esempio n. 42
0
 protected override void InitializeOnAwake() {
     base.InitializeOnAwake();
     _eventMgr = GameEventManager.Instance;
 }
 void Awake() {
     IncrementInstanceCounter();
     eventMgr = GameEventManager.Instance;
     eventMgr.Raise<SceneStartupSequenceEvent>(new SceneStartupSequenceEvent(this, SceneStartupEventName.Awake));
 }
Esempio n. 44
0
    void Awake()
    {
        Health = 1;

        m_GameEventManager = FindObjectOfType<GameEventManager>();
    }
 public void Awake()
 {
     if (instance==null){
         instance=this;
     }
 }
Esempio n. 46
0
    private void Initialize() {
        eventManager = GameEventManager.Instance;
        eventManager.AddListener<FocusSelectedEvent>(OnFocusSelected);

        _transform = transform;    // cache it! transform is actually GetComponent<Transform>()
        dummyTargetGO = GameObject.Find(MiscellaneousPhrases.DummyCameraTargetGameObject);
        if (dummyTargetGO == null) {
            dummyTargetGO = new GameObject(MiscellaneousPhrases.DummyCameraTargetGameObject);
        }
        IsResetOnFocus = true;
        IsRollEnabled = true;

        // TODO initial camera position should be focused on the player's starting planet, no rotation

        // initialize to WorldSpace no rotation
        _transform.rotation = Quaternion.identity;
        xRotation = Vector3.Angle(Vector3.right, _transform.right);  // same as 0.0F
        yRotation = Vector3.Angle(Vector3.up, _transform.up);    // same as 0.0F
        zRotation = Vector3.Angle(Vector3.forward, _transform.forward);  // same as 0.0F

        //Debug.Log("Camera initialized. Camera Rotation = " + _transform.rotation);
        focusTransform = null;

        Vector3 screenCenter = new Vector3(Screen.width / 2, Screen.height / 2, 0);
        TrySetNewFreeZoomTargetAt(screenCenter, 50F);   // UNDONE for now, create a temporary target just in front of the camera 

        ChangeState(CameraState.Freeform);
        isInitialized = true;
    }
Esempio n. 47
0
    // Use this for initialization
    void Start()
    {
        m_Rigidbody = GetComponent<Rigidbody>();

        m_GameEventManager = FindObjectOfType<GameEventManager>();
    }
    private void Initialize() {
        eventManager = GameEventManager.Instance;
        eventManager.AddListener<FocusSelectedEvent>(OnFocusSelected);

        _transform = transform;    // cache it as transform is actually GetComponent<Transform>()
        dummyTargetGO = GameObject.Find("Temp Camera Target");
        if (dummyTargetGO == null) {
            dummyTargetGO = new GameObject("Temp Camera Target");
        }
        IsResetOnFocus = true;
        IsRollEnabled = true;

        // TODO initial camera position should be focused on the player's starting planet, no rotation
        cameraPosition = _transform.position;

        // initialize to WorldSpace no rotation
        cameraRotation = Quaternion.identity;
        _transform.rotation = cameraRotation;
        xRotation = Vector3.Angle(Vector3.right, _transform.right);  // same as 0.0F
        yRotation = Vector3.Angle(Vector3.up, _transform.up);    // same as 0.0F
        zRotation = Vector3.Angle(Vector3.forward, _transform.forward);  // same as 0.0F

        Debug.Log("Camera initialized. Camera Rotation = " + cameraRotation);
        focusTransform = null;
        // for now, create a temporary target just in front of the camera 
        Vector3 screenCenter = new Vector3(Screen.width / 2, Screen.height / 2, 0);
        SetTargetAtScreenPoint(screenCenter);
        ChangeState(CameraState.Freeform);
        isInitialized = true;
    }
Esempio n. 49
0
 ///<summary>
 /// Called once from the constructor, this does all required initialization
 /// </summary>
 private void Initialize() {
     _gameStatus = GameStatus.Instance;
     _eventMgr = GameEventManager.Instance;
     UnityEngine.Time.timeScale = Constants.OneF;
     _playerPrefsMgr = PlayerPrefsManager.Instance;
     PrepareToBeginNewGame();
     _subscribers = new List<IDisposable>(); // placed here because GameTime exists in IntroScene. _subscribers is null when disposing there
 }
Esempio n. 50
0
 private void Start() {
     // Keep at a minimum, an empty Start method so that instances receive the OnDestroy event
     eventManager = GameEventManager.Instance;
 }
Esempio n. 51
0
 protected override void Awake() {
     base.Awake();
     _playerPrefsMgr = PlayerPrefsManager.Instance;
     _eventMgr = GameEventManager.Instance;
 }
 public AMortalItemPresenter(IViewable view)
     : base(view) {
     _eventMgr = GameEventManager.Instance;
     Subscribe();
 }
Esempio n. 53
0
 protected override void Awake() {
     base.Awake();
     _eventMgr = GameEventManager.Instance;
     _readoutLabel = gameObject.GetSafeMonoBehaviourComponent<UILabel>();
 }
Esempio n. 54
0
    private void Initialize() {
        eventManager = GameEventManager.Instance;
        eventManager.AddListener<FocusSelectedEvent>(OnFocusSelected);

        cameraTransform = transform;    // cache it! transform is actually GetComponent<Transform>()

        dummyTargetGO = GameObject.Find(MiscellaneousPhrases.DummyCameraTargetGameObject);
        if (dummyTargetGO == null) {
            dummyTargetGO = new GameObject(MiscellaneousPhrases.DummyCameraTargetGameObject);
        }
        PlaceDummyTargetAtUniverseEdgeInDirection(cameraTransform.forward);
        // Add the collider after placing the DummyTarget so the placement algorithm doesn't accidently find it already in front of the camera
        dummyTargetGO.AddComponent<SphereCollider>().enabled = true;
        dummyTargetGO.layer = (int)Layers.DummyTarget;

        IsResetOnFocusEnabled = true;
        IsRollEnabled = true;
        IsScrollZoomOutOnCursorEnabled = true;

        // UNDONE initial camera position should be focused on the player's starting planet, no rotation
        // initialize to WorldSpace no rotation
        cameraTransform.rotation = Quaternion.identity;
        xRotation = Vector3.Angle(Vector3.right, cameraTransform.right);  // same as 0.0F
        yRotation = Vector3.Angle(Vector3.up, cameraTransform.up);    // same as 0.0F
        zRotation = Vector3.Angle(Vector3.forward, cameraTransform.forward);  // same as 0.0F

        Debug.Log("Camera initialized. Camera Rotation = " + cameraTransform.rotation);
        focusTransform = null;

        ChangeState(CameraState.Freeform);
        isInitialized = true;
    }
Esempio n. 55
0
 // Use this for initialization
 void Start()
 {
     m_GameEventManager = FindObjectOfType<GameEventManager>();
 }
Esempio n. 56
0
    /// <summary>
    /// 用來作初始化
    /// </summary>
    void Start()
    {
        _gameGUIPanel = GameGUIPanel.Instance;

        _gameState = GameNone.Instance;
        _dataTableManager = new DataTableManager();
        _sceneManager = new SceneManager();
        _playerInput = PlayerInput.Instance;
        _cameraManager = new CameraManager();
        _gameEventManager = new GameEventManager();
        _gameEventState = new GameEventState();

        _npcUnitManager = NPCUnitManager.Instance;

        // 進入遊戲前需處理好的class,加載位置可能要換
        _startDependencies.Add(_dataTableManager);
    }
Esempio n. 57
0
 void Awake() {
     _eventMgr = GameEventManager.Instance;
     _transform = transform;
     _collider = collider as SphereCollider;
     UpdateRate = FrameUpdateFrequency.Continuous;
 }
Esempio n. 58
0
 void OnDestroy()
 {
     _gameGUIPanel = null;
     _gameState = null;
     _dataTableManager = null;
     _sceneManager = null;
     if (_playerInput != null)
     {
         Destroy(_playerInput);
         _playerInput = null;
     }
     _cameraManager = null;
     _gameEventManager = null;
     _gameEventState = null;
     if (_npcUnitManager != null)
     {
         Destroy(_npcUnitManager);
         _npcUnitManager = null;
     }
     _instance = null;
 }
Esempio n. 59
0
 protected override void Awake() {
     base.Awake();
     _eventMgr = GameEventManager.Instance;
 }
Esempio n. 60
0
 protected virtual void InitializeOnAwake() {
     UnityUtility.ValidateComponentPresence<Collider>(gameObject);
     _transform = transform;
     _collider = gameObject.GetComponent<Collider>();
     _eventMgr = GameEventManager.Instance;
 }