Inheritance: MonoBehaviour
Esempio n. 1
0
        private void RestartGame()
        {
            physics.NewGameSettings();

            this.obstacleCounter = 0;
            this.RestartNextObstacle();

            player.Left = (ClientRectangle.Width - player.Width) / 2;
            player.Top  = 25;
            maxHeight   = player.Top;
            foreach (var item in ob)
            {
                this.Controls.Remove(item);
            }
            ob.Clear();
            score    = 0;
            gameOver = false;
            GameClock.Stop();
            ScoreLabel.Text = "Score: " + score.ToString("D8");
            SetHighScore();
            MsgLabel.Text         = "Press Space to Start";
            OptionsLabel.Text     = "Select Game Mode  \n('S' to switch)  ";
            JustBounceLabel.Text  = "JustBounce";
            BounceNJumpLabel.Text = "BounceNJump";

            BoldGameMode();
        }
        /// <summary>
        /// When a clock property changed
        /// </summary>
        /// <param name="pSender"></param>
        /// <param name="pEventArgs"></param>
        private void OnClockPropertyChanged(object pSender, PropertyChangedEventArgs pEventArgs)
        {
            if (pSender is GameClock)
            {
                GameClock lClock = pSender as GameClock;

                switch (pEventArgs.PropertyName)
                {
                case "isStarted":
                    if (lClock.isStarted)
                    {
                        Debug.Log("Clock started");
                    }
                    else
                    {
                        Debug.Log("Clock paused");
                    }
                    break;

                case "speed":
                    Debug.Log(string.Format("Speed : x{0}", lClock.speed));
                    break;

                case "days":
                    Debug.Log(string.Format("{0} day(s)", lClock.days));
                    break;
                }
            }
        }
Esempio n. 3
0
        private void Begin_Click(object sender, EventArgs e)
        {
            if (beginBtnClk == false)
            {
                beginBtnClk       = true;
                GameTimer.Enabled = true;
                GameTimer.Start();

                GameClock.Enabled = true;
                GameClock.Start();

                Begin.Image = global::Snake.Properties.Resources.暂停;
                Begin.Refresh();
            }
            else
            {
                beginBtnClk       = false;
                GameTimer.Enabled = false;
                GameTimer.Stop();

                GameClock.Enabled = false;
                GameClock.Stop();

                Begin.Image = global::Snake.Properties.Resources.播放;
                Begin.Refresh();
            }
        }
Esempio n. 4
0
    private bool IsGaramonTime()
    {            //Is it time for a garamon dream
        //if (Quest.instance.isTybalDead)
        //{
        if (Quest.instance.GaramonDream == 6)
        {
            return(true);                                   //All done.
        }
        if (Quest.instance.GaramonDream == 7)
        {
            return(true);                                   //Tybal is dead. Time to play a dream.
        }
        //}
        //else
        //{
        //	if (Quest.instance.GaramonDream>7)
        //	{
        //		return false;//All done until tybal is dead.
        //	}
        //}

        if (GameClock.day() >= Quest.instance.DayGaramonDream)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 5
0
    public IEnumerator RunSyncInterval()
    {
        long[] resultArr = new long[2];      // it will contain NTP time and local time

        EPADApplication.Instance.timeSyncLog.LogNTPSyncEvent(true);
        gameClock._ntpSync.QueryNTPTime();
        yield return(new WaitForSeconds(0.1f));

        while (!gameClock._ntpSync.didUpdateNTP)
        {
            yield return(0);
        }

        DateTime currentNTPTime = gameClock._ntpSync.lastSyncedNTPTime;

        EPADApplication.Instance.timeSyncLog.LogNTPSyncEvent(false);
        long ntpTime    = GameClock.GetClockMilliseconds(currentNTPTime);
        long localTime  = GameClock.GetClockMilliseconds(DateTime.Now);
        long difference = ntpTime - localTime;

        EPADApplication.Instance.debugText.text = "Last timestamp: " + ntpTime.ToString();
        Debug.Log("difference is " + difference.ToString());
        resultArr[0] = ntpTime;
        resultArr[1] = localTime;
        EPADApplication.Instance.timeSyncLog.LogEPADSyncTime(resultArr);
        yield return(null);
        //return resultArr;
        //NetworkManager.Instance.SendMessageToEPAD(message);
        //TreasureHuntController_ARKit.Instance.trialLog.LogTimeSyncEvent(ntpTime, localTime, difference);
    }
Esempio n. 6
0
        // Finds the next value that is in the future and removes old values from the list
        private uint FindNextValue()
        {
            List <uint> oldKeys     = new List <uint>();
            uint        foundKey    = 0;
            uint        CurrentTick = GameClock.GetRemoteTick();

            // Find the next value
            foreach (uint key in ValueList.Keys)
            {
                if (key > CurrentTick)
                {
                    foundKey = key;
                    break;
                }

                oldKeys.Add(key);
                LastClockedValue = new KeyValuePair <uint, T>(key, GetValueForTick(key));
            }

            // Remove old
            if (oldKeys.Count > 0)
            {
                oldKeys.ForEach(k => ValueList.Remove(k));
            }

            return(foundKey);
        }
Esempio n. 7
0
        private GameDetail GetDetailFromGame(Game game, IEnumerable <Score> allScores)
        {
            var awayScore = allScores
                            .Where(x => x.TeamId == game.AwayTeamId)
                            .Sum(x => x.Points);

            var homeScore = allScores
                            .Where(x => x.TeamId == game.HomeTeamId)
                            .Sum(x => x.Points);

            var gameClock = _gameEngineListener.GetGameClockById(game.Id);

            if (gameClock.IsNull())
            {
                gameClock = new GameClock();
            }

            var gameDetail = new GameDetail
            {
                Id         = game.Id,
                Name       = game.Name,
                Quarter    = gameClock.Quarter,
                GameClock  = gameClock.Time.ToCustomString("mm:ss.f"), // Render as a game clock,
                AwayTeamId = game.AwayTeamId,
                AwayScore  = awayScore,
                HomeTeamId = game.HomeTeamId,
                HomeScore  = homeScore
            };

            return(gameDetail);
        }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GameOverScreen"/> class.
        /// </summary>
        public GameOverScreen(uint score)
            : base()
        {
            this.score = score;
            this.actionAvailableTime = DateTime.Now.Ticks + 30000000;
            GameClock.Pause();

            this.textDrawPosition  = new Vector2(0, -125);
            this.textDrawOrigin    = FontStatic.Get("defaultFont").MeasureString("Game Over") / 2f;
            this.scoreLogoPosition = new Vector2(0, -20f);
            this.scoreLogoOrigin   = FontStatic.Get("defaultFont").MeasureString("Score") / 2f;
            this.scorePosition     = new Vector2(0, 50f);
            this.scoreOrigin       = FontStatic.Get("defaultFont").MeasureString(Drawer.FormatNumber(this.score)) / 2f;
            this.aButtonPosition   = new Vector2(-240f, 150f);
            this.bButtonPosition   = new Vector2(100f, 150f);
            this.actionXOffset     = new Vector2(50f, 0);
            this.buttonOrigin      = FontStatic.Get("ControllerFont").MeasureString(")") / 2f;
            this.aActionOrigin     = new Vector2(0, FontStatic.Get("defaultFont").MeasureString("Replay").Y / 2);
            this.bActionOrigin     = new Vector2(0, FontStatic.Get("defaultFont").MeasureString("Quit").Y / 2);
            this.buttonColor       = Color.Transparent;

            this.position = new tVector2(1920f / 2f - 2000f, 1080f / 2f);
            this.position.GoTo(1920f / 2f, 1080f / 2f, 0.3f, true);
            this.background = new HypercubeDisplay(
                new Rectangle((int)(this.position.Value.X - 685f / 2f) - 3, (int)(this.position.Value.Y - 370f / 2f) - 3, 685 + 6, 370 + 6),
                3,
                this.random,
                0.2f);
        }
Esempio n. 9
0
        void Start()
        {
            Text = name;
            transform.rotation = cam.transform.rotation;
            Rigidbody rb = GetComponent <Rigidbody>();

            rb.velocity = Vector3.up * speed;
            long timing = (long)(duration * 1000);

            GameClock.Delay(timing, () => Destroy(gameObject));
            if (fade)
            {
                TMPro.TMP_Text tt = TmpText;
                Color          originalFace = tt.faceColor, originalOutline = tt.outlineColor;
                Proc.SystemClock.Lerp(p => {
                    if (tt != null)
                    {
                        tt.faceColor       = Color.Lerp(originalFace, Color.clear, p);
                        tt.outlineColor    = Color.Lerp(originalOutline, Color.clear, p);
                        transform.rotation = cam.transform.rotation;
                    }
                    //Show.Log(p);
                }, timing, 10);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Updates this instance. This makes sure that GameClock is paused,
        /// and it also updates the menu.
        /// </summary>
        public override void Update()
        {
            base.Update();
            // Only pause the gameclock if the screen is not fading out.
            if (!this.FadingOut)
            {
                GameClock.Pause();
            }
            else
            {
                GameClock.Unpause();
            }

            this.position.Update();

            // If it is fading out and the pause menu is done moving, then dispose.
            if (this.FadingOut && !this.position.IsTransitioning)
            {
                GameClock.Unpause();
                this.Disposed = true;
            }

            if (GameElements.GameWorld.controller.ContainsBool(Inputs.ActionType.BButtonFirst))
            {
                Quit();
            }
        }
Esempio n. 11
0
    // Use this for initialization
    private void Start1()
    {
        Debug.logger.logEnabled = true; //  关闭日志输出

        Mafia.Instance.InitPlugin();

        var plugin = Mafia.Instance.GetPlugin <MafiaPlugin>();

        Debug.Log("Plugin is " + plugin);


        //  测试pb
        var info = new LoginBean
        {
            OpenId = "1998"
        };

        Debug.Log(info);
        var m_data = info.ToByteArray();
        //
        var tgt_bean = LoginBean.Parser.ParseFrom(m_data);

        Debug.Log(tgt_bean);

        //
        Debug.Log(GameClock.Now());
        Debug.Log(GameClock.Timestamp);
        Debug.Log(DateTime.Now);
        Debug.Log(DateTime.Now.ToFileTimeUtc());
    }
Esempio n. 12
0
 public void Blink()
 {
     //Debug.Log("blink");
     gameObject.SetActive(false);
     pending.Clear();
     GameClock.Delay(0, () => gameObject.SetActive(true));
 }
Esempio n. 13
0
    public void PickUp(GameObject finder)
    {
        //Show.Log(finder+" picked up "+specificName+"("+typeName+")");
        Game     game = Global.Get <Game>();
        Vector3  p    = transform.position;
        Material mat  = GetComponent <Renderer>().material;

        GameClock.Delay(0, () => {         // make sure object creation happens on the main thread
            FloatyText ft        = FloatyTextManager.Create(p + (Vector3.up * game.maze.tileSize.y * game.maze.wallHeight), kind);
            ft.TmpText.faceColor = mat.color;
        });
        // find which NPC wants this, and make them light up
        ParticleSystem ps = null;
        //Show.Log(specificName+" turns on particle for "+typeName);
        CharacterRoot npc = game.npcCreator.npcs.Find(n => {
            ps = n.GetComponentInChildren <ParticleSystem>();
            //Show.Log(ps.name + " v " + typeName);
            if (ps != null && ps.name == color)
            {
                return(true);
            }
            ps = null;
            return(false);
        });

        if (npc != null && ps != null)
        {
            ps.Play();
        }
    }
Esempio n. 14
0
 public Meter(Rectangle position)
 {
     Position        = position;
     HorizontalMeter = true;
     Clock           = new GameClock();
     IsVisible       = true;
 }
Esempio n. 15
0
    public void AddToPlayerInventory(InventoryItem ii)
    {
        Vector3  p   = ii.transform.position;
        Material mat = ii.GetComponent <Renderer>().material;

        GameClock.Delay(0, () => {         // make sure object creation happens on the main thread
            FloatyText ft        = FloatyTextManager.Create(p + (Vector3.up * game.maze.tileSize.y * game.maze.wallHeight), mat.name);
            ft.TmpText.faceColor = mat.color;
        });
        // find which NPC wants this, and make them light up
        ParticleSystem ps  = null;
        CharacterRoot  npc = game.npcCreator.npcs.Find(n => {
            ps = n.GetComponentInChildren <ParticleSystem>();
            if (ps.name == mat.name)
            {
                return(true);
            }
            ps = null;
            return(false);
        });

        if (npc != null)
        {
            ps.Play();
        }
    }
Esempio n. 16
0
        public EditorApp(
            ImGuiRenderer imGuiRenderer,
            GameWindow gameWindow,
            IReadOnlyList <IWindow> windows,
            GameClock gameClock,
            WorldSystem worldSystem,
            EditTileMapState editTileMapState,
            IAssetsDatabase assetsDatabase
            )
        {
            _imGuiRenderer  = imGuiRenderer;
            _windows        = windows;
            _gameClock      = gameClock;
            _worldSystem    = worldSystem;
            _editorAppState = editTileMapState;
            _assetsDatabase = assetsDatabase;

            _imGuiRenderer.RebuildFontAtlas();
            var imGuiIo = ImGui.GetIO();

            imGuiIo.ConfigWindowsMoveFromTitleBarOnly = true;
            imGuiIo.ConfigFlags |= ImGuiConfigFlags.DockingEnable;

            gameWindow.AllowUserResizing = true;

            _worldSystem.CreateNewWorld();
        }
Esempio n. 17
0
        /// <summary>
        /// Updates this instance. This makes sure that GameClock is paused,
        /// and it also updates the menu.
        /// </summary>
        public override void Update()
        {
            base.Update();

            // Only pause the gameclock if the screen is not fading out.
            if (!this.FadingOut)
            {
                GameClock.Pause();
            }
            else
            {
                GameClock.Unpause();
            }

            this.position.Update();

            // If it is fading out and the pause menu is done moving, then dispose.
            if (this.FadingOut && !this.position.IsTransitioning)
            {
                GameClock.Unpause();
                this.Disposed = true;
            }

            this.menu.position = this.position.Value;
            this.menu.Update();
            this.background.Set(this.position.X.Value, this.position.Y.Value);
            this.background.Update();
        }
Esempio n. 18
0
        private void DoTimer()
        {
            Timer self  = this;
            long  delay = (long)(seconds * 1000);

            if (repeat)
            {
                GameClock.Delay(delay, () => {
                    if (self == null)
                    {
                        return;
                    }
                    DoTimer();
                });
            }
            Incident todo;
            object   whatToDo = whatToActivate.Data;
            bool     activate = !deactivate;

            if (relentlessTimer)
            {
                todo = GameClock.Delay(delay, () => ActivateAnything.DoActivate(whatToDo, this, null, activate));
            }
            else
            {
                todo = GameClock.Delay(delay, () => {
                    if (self == null)
                    {
                        return;                                   // if this timer is destroyed, don't activate
                    }
                    ActivateAnything.DoActivate(whatToDo, this, null, activate);
                });
            }
            todo.Source = this;
        }
Esempio n. 19
0
        public override void CheckForValueUpdate()
        {
            // Check if we are the owner of this
            if (ShouldReplicate())
            {
                return;
            }

            uint RemoteTick   = GameClock.GetRemoteTick();
            bool ValueChanged = false;

            // Find the most recent update
            List <uint> touchedKeys = new List <uint>();

            foreach (uint key in ValueList.Keys)
            {
                if (key > RemoteTick)
                {
                    break;
                }

                ValueList[key].ForEach(parameters => GetCommandReplicator().MDProcessCommand((object[])parameters));
                ValueChanged = true;
                touchedKeys.Add(key);
            }

            if (ValueChanged)
            {
                // Remove old
                touchedKeys.ForEach(k => ValueList.Remove(k));

                // Send event
                CallOnChangeCallback();
            }
        }
Esempio n. 20
0
        public override void Draw(IScreen screen, GameClock gameTime)
        {
            if (!ShouldDraw(screen))
            {
                return;
            }

            //Get the font to use
            var font = GetFont();

            //make sure the shadow color is correct
            var shadow = font as ShadowTextBuddy;

            if (null != shadow)
            {
                shadow.ShadowColor = screen.Transition.AlphaColor(GetShadowColor());
            }

            //adjust the pulsate scale
            var pulsate = font as PulsateBuddy;

            if (Highlightable && null != pulsate)
            {
                pulsate.PulsateSize = IsClicked ? 1.2f : 1f;
            }

            //Write the text
            font.Write(Text,
                       TextPosition(screen),
                       AlignmentToJustify(),
                       Scale,
                       screen.Transition.AlphaColor(GetColor()),
                       screen.ScreenManager.SpriteBatch,
                       HighlightClock);
        }
Esempio n. 21
0
        public override void Update(GameClock time)
        {
            base.Update(time);

            //update all timers
            TimeClock.Update(time);
        }
Esempio n. 22
0
    public void SendEvent(long systemTime, TCP_Config.EventType eventType, string eventData, string auxData)
    {
        //Format the message
        //(from the python code:) TODO: Change to JSONRPC and add checksum
        string t0      = GameClock.FormatTime(systemTime);
        string message = TCP_Config.MSG_START + t0 + TCP_Config.MSG_SEPARATOR + "ERROR" + TCP_Config.MSG_END;

        if (auxData.Length > 0)
        {
            message = TCP_Config.MSG_START
                      + t0 + TCP_Config.MSG_SEPARATOR
                      + eventType.ToString() + TCP_Config.MSG_SEPARATOR
                      + eventData + TCP_Config.MSG_SEPARATOR
                      + auxData + TCP_Config.MSG_END;
        }
        else if (eventData.Length > 0)
        {
            message = TCP_Config.MSG_START
                      + t0 + TCP_Config.MSG_SEPARATOR
                      + eventType.ToString() + TCP_Config.MSG_SEPARATOR
                      + eventData + TCP_Config.MSG_END;
        }
        else
        {
            message = TCP_Config.MSG_START
                      + t0 + TCP_Config.MSG_SEPARATOR
                      + eventType.ToString() + TCP_Config.MSG_END;
        }

        messagesToSend += message;

        TCPServer.Instance.Log(systemTime, eventType);
    }
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            graphics.IsFullScreen = false;

            _circle1 = new Circle();
            _circle2 = new Circle();

            _clock = new GameClock();

            //Setup the input for this game.
            _inputState             = new InputState();
            Mappings.UseKeyboard[0] = true;             //Set the first player to use the keyboard.
            _controller             = new ControllerWrapper(0);
            _inputWrapper           = new InputWrapper(_controller, _clock.GetCurrentTime);


            var resolution = new ResolutionComponent(this,
                                                     graphics,
                                                     new Point(1280, 720), //The desired virtual resolution that items in the game will be drawn with
                                                     new Point(1280, 720), //The desired physical resolution to set the screen.
                                                     false,                //Flag whether or not to fullscreen the app
                                                     true,                 //Flag whether or not to letterbox the app to fit the aspect ratio of virtual/screen resolutions.
                                                     false);               //This flag can be used to set it to use the entire screen BUT without setting the Device.Fullscreen flag.

            //set up the camera
            _camera = new Camera();

            //The WorldBoundary is a rectangle that the Camera will try to stay inside. When the circle moves out of this rectangle it will appear to go offscreen.
            _camera.WorldBoundary = new Rectangle(0, 0, 1280, 720);
        }
Esempio n. 24
0
        public TimerMeter(float maxTime, ContentManager content, string borderImage, string meterImage, string alphaMaskImage, Rectangle position) :
            base(position)
        {
            TimeClock = new GameClock();

            MaxTime     = maxTime;
            CurrentTime = MaxTime;

            TimeColors = new List <Color> {
                new Color(80, 0, 0), new Color(240, 0, 0)
            };
            DepletedTimeColor = new Color(0.8f, 0.8f, 0.8f);
            TimeColorSpeed    = 1f;

            NearEndTime          = MaxTime * 0.4f;
            NearEndColorSpeed    = 10f;
            NearEndPulsateSpeed  = 15f;
            NearEndPulsateAmount = 0.11f;
            NearEndColors        = new List <Color> {
                Color.Red, new Color(0.4f, 0f, 0f), Color.HotPink
            };

            TimeOutShakeSpeed = 50f;
            TimeOutShakeScale = 8f;
            TimeOutColors     = new List <Color> {
                Color.Red, new Color(0.9f, 0.8f, 0f), new Color(0.4f, 0f, 0f), DepletedTimeColor
            };
            TimeOutColorSpeed = 5f;

            LoadContent(content, new Filename(borderImage), new Filename(meterImage), new Filename(alphaMaskImage));
        }
Esempio n. 25
0
        public override void Draw(IScreen screen, GameClock gameTime)
        {
            DrawStuff(screen, gameTime, base.Draw, false);

            //render the texture
            var rect = CalculateRect();

            screen.ScreenManager.SpriteBatch.Draw(_renderTarget,
                                                  TransitionObject.Position(screen.Transition, rect.Location),
                                                  Color.White);

            //Draw the scroll bars if the mouse pointer or a touch is inside the layout
            if (ShowScrollBars && DrawScrollbars)
            {
                if (DrawVerticalScrollBar)
                {
                    screen.ScreenManager.DrawHelper.DrawRect(StyleSheet.HighlightedBackgroundColor, VerticalScrollBar, screen.Transition, TransitionObject);
                }

                if (DrawHorizontalScrollBar)
                {
                    screen.ScreenManager.DrawHelper.DrawRect(StyleSheet.HighlightedBackgroundColor, HorizontalScrollBar, screen.Transition, TransitionObject);
                }
            }
        }
        private void IncrementGameClock(GameClock gameClock, TimeSpan elapsed)
        {
            // Rather than have every game increment time in the same sequence - add some variability
            var variableTime = TimeSpan.FromMilliseconds(_random.Any(-(int)elapsed.TotalMilliseconds, (int)elapsed.TotalMilliseconds));

            // Add more variable time, if it is above 0
            var gameElapsed = elapsed + (variableTime > TimeSpan.Zero ? variableTime : TimeSpan.Zero);

            //
            var newClockTime = gameClock.Time - gameElapsed;

            // Ensure the clock is rounded to the nearest tenth of a second
            newClockTime = newClockTime.RoundToNearest(TimeSpan.FromMilliseconds(100));

            // Check if time has expired for the current quarter
            if (newClockTime > TimeSpan.Zero)
            {
                gameClock.Time = newClockTime;
            }
            else
            {
                //
                if (gameClock.Quarter >= GameClock.NumberOfQuarters)
                {
                    // Game is over
                    gameClock.Time = TimeSpan.Zero;
                    return;
                }

                gameClock.Quarter++;
                gameClock.Time = GameClock.TimeEachQuarter + newClockTime; // In this case, new time is negative
            }
        }
Esempio n. 27
0
 void Start()
 {
     gameClock        = GetComponent <GameClock>();
     tetrominoManager = GetComponent <TetrominoManager>();
     scoreKeeper      = GetComponent <ScoreKeeper>();
     board            = transform.Find("Board").GetComponent <Board>();
 }
Esempio n. 28
0
 public virtual void Draw(IScreen screen, GameClock gameTime)
 {
     //draw all the items
     for (int i = 0; i < Items.Count; i++)
     {
         Items[i].Draw(screen, gameTime);
     }
 }
Esempio n. 29
0
 public virtual void Update(IScreen screen, GameClock gameTime)
 {
     //update all the items
     for (int i = 0; i < Items.Count; i++)
     {
         Items[i].Update(screen, gameTime);
     }
 }
Esempio n. 30
0
        private void renderDisplay_OnInitialize(object sender, EventArgs e)
        {
            mGameTime    = new GameClock();
            mBasicEffect = new BasicEffect(GraphicsDevice);
            mCamera      = new MouseCamera(GraphicsDevice);

            Visible = false;
        }
Esempio n. 31
0
	void Awake(){
		
		if (_instance != null) {
			Debug.Log("Instance already exists!");
			Destroy(transform.gameObject);
			return;
		}
		_instance = this;
	}
Esempio n. 32
0
 void Start()
 {
     settings = GameSettings.Instance;
     Clock = new GameClock(DateTime.Now);
     unprocessActions = new Queue<Action>();
     InitializeClient();
 }
Esempio n. 33
0
 public void __Init(GameClock clock)
 {
     _clock = clock;
     _running = true;
 }
Esempio n. 34
0
    // Use this for initialization
    public override void Awake()
    {
        if (_instance != null)
            throw new Exception("You can only create one Stage");
        _instance = this;

        Name = "Stage";

        _holder = new GameObject("StageContainer");
        _clock = new GameClock("DefaultClock");
        _holder.AddComponent<Library>();
        _holder.AddComponent<MouseInput>();

        _camera = camera;
        _camera.orthographic = true;
        _camera.transform.position = new Vector3(0, 0, CinchOptions.CameraPos);
        _camera.tag = "MainCamera";
        _holder.transform.parent = _camera.transform;
        RenderSettings.ambientLight = new Color(1f, 1f, 1f);

        var tweenRunner = gameObject.AddComponent<TweenRunner>();
        tweenRunner.__Init (_clock);
    }
Esempio n. 35
0
        public Engine(IKernel kernel)
        {
            _kernel = kernel;
            _resouces = new List<IResourceContainer>();
            _updatables = new List<IUpdatable>();
            _renderables = new List<IRenderable>();

            IDeviceProvider deviceProvider = kernel.Get<IDeviceProvider>();

            _form = deviceProvider.RenderForm;
            _form.ResizeBegin += OnResizeBegin;
            _form.ResizeEnd += OnResizeEnd;
            _form.FormClosed += OnFormClosed;
            _form.Resize += new EventHandler(OnFormResize);
            _form.KeyDown += new KeyEventHandler(_form_KeyDown);

            _device = new DeviceEx(deviceProvider.Device.NativePointer);
            _presentParameters = deviceProvider.PresentParameters;
            _totalGameTime = TimeSpan.Zero;
            _lastFrameElapsedGameTime = TimeSpan.Zero;
            _drawState = new DrawState();
            _updateState = new UpdateState();
            _clock = new GameClock();
        }
Esempio n. 36
0
 private void Client_NewDataReceived(object sender, NewDataReceivedEventArgs e)
 {
     CommandType cmdType = (CommandType)e.Data.PackageData.GetInt16(4);
     Debug.Log("*" + cmdType.ToString() + " command received!");
     switch (cmdType)
     {
         case CommandType.TimeSynchronization:
             TimeSynchronizationCommand tsc = CommandSerializer.Deserialize<TimeSynchronizationCommand>(e.Data.PackageData);
             int ping = (int)((DateTime.Now - tsc.ClientTime).TotalMilliseconds);
             ping /= 2;
             DateTime serverTime = tsc.ServerTime.AddMilliseconds(ping);
             this.Ping = ping;
             Clock = new GameClock(serverTime);
             break;
         case CommandType.Connected:
             ConnectedCommand cc = CommandSerializer.Deserialize<ConnectedCommand>(e.Data.PackageData);
             GameSettings.Instance.IsPlayerClient = cc.IsPlayer;
             this.Connected = true;
             break;
         case CommandType.PlayerStateChanged:
             PlayerStateChangedCommand pscc = CommandSerializer.Deserialize<PlayerStateChangedCommand>(e.Data.PackageData);
             InvokeAtMainThread(() => {
                 settings.Player.SendMessage("PlayerStateChanged", pscc);
             });
             break;
         case CommandType.MonsterStateChanged:
             MonsterStateChangedCommand mscc = CommandSerializer.Deserialize<MonsterStateChangedCommand>(e.Data.PackageData);
             InvokeAtMainThread(() =>
             {
                 MonsterManager.Instance.MonsterStateChanged(mscc);
             });
             break;
     }
 }
Esempio n. 37
0
 public void Setup()
 {
     clock = new GameClock();
 }