Exemple #1
0
    private void ChangeForm(PlayerForm form, bool instant = false)
    {
        IsChangingForm = true;
        CurrentForm    = form;

        GD.Print("Changing form to " + form.ToString());

        if (!SceneCache.ContainsKey(CurrentForm))
        {
            SceneCache.Add(CurrentForm, GD.Load <PackedScene>(Constants.FilePath.PLAYER_FORM_SCENES + CurrentForm.ToString() + ".tscn"));
        }
        CurrentScene = SceneCache[CurrentForm];

        string frameCacheKey = SpriteFolderName + "/" + CurrentForm.ToString();

        if (!FrameCache.ContainsKey(frameCacheKey))
        {
            FrameCache.Add(frameCacheKey, GD.Load <SpriteFrames>(Constants.FilePath.PLAYER_FRAMES + SpriteFolderName + "/" + CurrentForm.ToString() + ".tres"));
        }
        CurrentFrames = FrameCache[frameCacheKey];

        Player oldFormScene = GetChildCount() > 0 ? GetChildOrNull <Player>(0) : null;

        oldFormScene?.SetName("QueuedForDeletion");

        if (oldFormScene != null)
        {
            PreviousTransform = oldFormScene.GetGlobalTransform();
            PreviousVelocity  = oldFormScene.Velocity;

            AnimatedSprite3D sprite = GetNode <AnimatedSprite3D>(new NodePath("QueuedForDeletion/PlayerSprite"));
            PreviousSpriteFlipped = sprite.IsFlippedH();

            if (!instant)
            {
                //Create blinking state transition
                TransitionFrames.Clear("Transition");

                TransitionFrames.AddFrame("Transition", sprite.Frames.GetFrame(Player.PlayerAnimation.IDLE, 0), 0);
                TransitionFrames.AddFrame("Transition", CurrentFrames.GetFrame(Player.PlayerAnimation.IDLE, 0), 1);

                TransitionSprite.SetGlobalTransform(sprite.GetGlobalTransform().Translated(-Transform.origin));
                TransitionSprite.SetFlipH(sprite.FlipH);
                TransitionSprite.SetPixelSize(sprite.GetPixelSize());
                TransitionSprite.Play("Transition");
            }

            oldFormScene.SetProcess(false);
            oldFormScene.SetPhysicsProcess(false);
            oldFormScene.QueueFree();
        }

        if (instant)
        {
            FinishFormChange(form);
            return;
        }

        AddChild(TransitionSprite);
    }
Exemple #2
0
        // Called if the respective button is clicked in the player or main form
        public static void SwitchPlaybackScreen()
        {
            Screen mainFormScreen   = Screen.FromControl(MainForm);
            Screen playerFormScreen = Screen.FromControl(PlayerForm);
            int    oldIndex         = 0;
            int    newIndex         = 0;

            for (int i = 0; i < Screen.AllScreens.Length; i++)
            {
                if (Screen.AllScreens[i].Equals(playerFormScreen))
                {
                    oldIndex = i;
                    newIndex = (i == Screen.AllScreens.Length - 1 ? 0 : i + 1);
                    break;
                }
            }

            PlayerForm.WindowState = FormWindowState.Normal;
            PlayerForm.Location    = Screen.AllScreens[newIndex].Bounds.Location;
            PlayerForm.WindowState = FormWindowState.Maximized;
            lastPlayerFormScreen   = Screen.AllScreens[newIndex];

            if (Screen.AllScreens[newIndex].Equals(mainFormScreen))
            {
                int dx = MainForm.Location.X - mainFormScreen.Bounds.X;
                int dy = MainForm.Location.Y - mainFormScreen.Bounds.Y;

                MainForm.Location = Screen.AllScreens[oldIndex].Bounds.Location;
                MainForm.Location = new Point(MainForm.Location.X + dx, MainForm.Location.Y + dy);
            }

            PlayerForm.ReCenterControls();
        }
Exemple #3
0
        /// <summary>
        /// 盤上に駒を配置します。
        /// ゲームがすでに終了している場合、指定した位置にすでに駒が置かれている場合は何もしません。
        /// </summary>
        /// <param name="row">配置する行</param>
        /// <param name="column">配置する列</param>
        /// <param name="player">配置する駒</param>
        public void PutPiece(int row, int column, PlayerForm player)
        {
            if (GameStatus == GameStatus.Finished)
            {
                return;
            }

            if (this.board.BoardStatuses[row, column] != PlayerForm.None)
            {
                return;
            }

            this.board.PutPiece(row, column, player);
            BoardChanged?.Invoke(this, EventArgs.Empty);
            SwitchCurrentPleyer();
            (bool isGameEnded, PlayerForm winner) = CheckIfGameEnded(BoardSize, AlignNumber);
            if (isGameEnded)
            {
                this.GameStatus = GameStatus.Finished;
            }
            this.Winner = winner;
            if (isGameEnded)
            {
                GameEnded.Invoke(this, new GameEndedEventArgs(this.Winner));
            }
        }
 private void ConnectBTN_Click(object sender, RoutedEventArgs e)
 {
     FillPlayList();
     if (!string.IsNullOrEmpty(FolderPathTB.Text) &&
         Directory.Exists(FolderPathTB.Text))
     {
         if (RoomNameTB.Text.Length > 5 && RoomPasswordTB.Password.Length > 5)
         {
             var room = new Room {
                 UniqName = RoomNameTB.Text, Name = RoomNameTB.Text, Password = RoomPasswordTB.Password, Medias = Playlist
             };
             if (room.ConntectToRoom())
             {
                 room.Medias       = Playlist;
                 room.PlaylistPath = FolderPathTB.Text;
                 PlayerForm playerForm = new PlayerForm(room, false);
                 playerForm.Show();
                 this.Close();
             }
             else
             {
                 System.Windows.MessageBox.Show("Something went wrong....", "Sync Player");
             }
         }
         else
         {
             RoomNameTB.Clear();
             RoomPasswordTB.Clear();
         }
     }
     else
     {
         System.Windows.MessageBox.Show("You did not select playlist folder, or folder does not exist", "Filmst");
     }
 }
Exemple #5
0
 public void SetForm(PlayerForm form)
 {
     if (form != CurrentForm && !IsChangingForm)
     {
         ChangeForm(form);
     }
 }
        public void LogoIsDisplay()
        {
            HomeForm home = new HomeForm();

            Assert.AreEqual("2018 FIFA World Cup Russia™".ToLower(), home.Header.GetTitleText.ToLower());
            home.GoToPlayersForm();

            PlayersForm players = new PlayersForm();

            players.WaitForLoadingPage();
            Assert.IsTrue(players.IsFormTitleDisplay);

            PlayerBrowserSearchByPositionForm playerBrowser = players.SelectPlayer();

            playerBrowser.WaitForLoadingPage();
            Assert.IsTrue(playerBrowser.IsFormTitleDisplay);

            PlayerForm player = playerBrowser.GetInfo(new Random().Next(NUMBER_All_PLAYERS));

            player.WaitForLoadingPage();
            Assert.IsTrue(player.IsFormTitleDisplay);
            MatchSummaryForm matchSummary = player.SelectMatch(new Random().Next(NUMBER_OF_MATCHES));

            Assert.IsTrue(matchSummary.IsFormTitleDisplay);

            MatchForm match = matchSummary.GoToMatchForm();

            match.WaitForLoadingPage();
            Assert.IsTrue(match.IsFormTitleDisplay);
            Assert.IsTrue(match.IsLogoPresented);
        }
Exemple #7
0
 public static void OnMediaError(object sender, EventArgs e)
 {
     if (PlayerForm != null && PlayerForm.IsDisposed == false)
     {
         PlayerForm.Invoke(new Action(() => { PlayerForm.OnMediaError(sender, e); }));
     }
 }
    private void Update()
    {
        //Count up time and display it
        if (raceActive)
        {
            time           += Time.deltaTime;
            uiTimeText.text = $"{time:#0.000}";
        }

        if (Input.GetKeyDown(KeyCode.F5) && SteamManager.Initialized)
        {
            steamLeaderboard.DownloadScores();
        }

        if (Input.GetKeyDown(KeyCode.Return) && !SteamManager.Initialized)
        {
            eventLeaderboard.ClearEmptyPlayers();

            int exitCode = PlayerForm.AddPlayer(eventLeaderboard.scoreListPath);

            if (exitCode > 0)
            {
                eventLeaderboard.LoadScoreList();

                LocalScoreEntry newPlayer = eventLeaderboard.InitPlayer();

                eventPlayerName = newPlayer.playerName;
                cachedEmail     = newPlayer.email;

                LoadNewPlayerStats();
            }
        }
    }
Exemple #9
0
        /// <summary>
        /// 播放按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Download_MouseClick(object sender, DuiMouseEventArgs e)
        {
            //播放视频
            DuiButton dbn = sender as DuiButton;

            Entity.MovieListEntity.DataItem moveInfo = new Entity.MovieListEntity.DataItem();
            if (dbn.Tag != null)
            {
                moveInfo = dbn.Tag as Entity.MovieListEntity.DataItem;
            }
            string url = "";

            try
            {
                API.TvAPI             tva  = new API.TvAPI();
                Entity.MovePlayEntity plav = tva.getVideoUrl(userEntity.email, userEntity.psw, moveInfo.videoID.ToString(), "all", userEntity.imei);
                Console.WriteLine(plav.toJsonString());
                Console.WriteLine(plav.data);
                PlayerForm plF = new PlayerForm();
                url        = plav.data.ToString();
                plF.tvUrl  = plav.data.ToString();
                plF.tvName = moveInfo.videoName;
                plF.Show();
                plF.AxPlayer_PlayOrPause(url);
            }
            catch (Exception ex)
            {
                Logger.Singleton.Error("name:" + moveInfo.videoName + "---地址:" + url, ex);
                throw;
            }
        }
Exemple #10
0
    public void SwitchFormNext()
    {
        Vector3 pos = currentPlayerForm.transform.position;

        currentPlayerForm.FreezePosition(true);
        currentPlayerForm.gameObject.SetActive(false);

        int currentPlayerFormIndex = playerForms.IndexOf(currentPlayerForm.transform);
        int nextPlayerFormIndex    = currentPlayerFormIndex + 1;

        if (nextPlayerFormIndex >= playerForms.Count)
        {
            nextPlayerFormIndex = 0;
        }

        currentPlayerForm = playerForms[nextPlayerFormIndex].GetComponent <PlayerForm>();

        currentPlayerForm.gameObject.SetActive(true);
        currentPlayerForm.TeleportToPosition(pos);
        currentPlayerForm.FreezePosition(false);

        Camera.main.GetComponent <MyCamera>().target = currentPlayerForm.transform;

        // TODO: merge SwichForm functions into one
    }
Exemple #11
0
 public void ChangeToMelted()
 {
     Animator.SetTrigger("isChanging");
     NormalController.enabled = false;
     MeltedController.enabled = true;
     PlayerForm = PlayerForm.Melted;
 }
Exemple #12
0
 void SetRespawnSettings()
 {
     jetpackFuelCurrent = jetpackFuelMax;
     form = PlayerForm.Respawning;
     rigid.gravityScale = 0f;
     rigid.velocity     = Vector2.zero;
 }
Exemple #13
0
        public GameController(ContentManager Content, GraphicsDeviceManager graphics)
        {
            camera = new Camera(graphics.GraphicsDevice.Viewport);
            level = new Level();
            content = Content;
            currentPlayerForm = PlayerForm.Square;

            Tiles.Content = Content;

            level.Generate(new int[,]
            {
                {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
                {0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0},
                {0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,9},
                {1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,0,1,1,0,0,1,1,0,0,1,1,0,0,0,1,1,1,0,1,1,1,1,1,0,0,0,1,1},
            }, 48);

            // If new game, load this player texture.
            playerTexture = Content.Load<Texture2D>("PlayerSquare");

            playerSimulation = new PlayerSimulation();
            playerView = new PlayerView(camera, playerSimulation);
        }
Exemple #14
0
    public void SwitchForm(GameObject form)
    {
        if (form.name.Equals(currentPlayerForm.name))
        {
            return;
        }

        Vector3 pos = currentPlayerForm.transform.position;

        currentPlayerForm.FreezePosition(true);
        currentPlayerForm.gameObject.SetActive(false);

        foreach (Transform pf in playerForms)
        {
            if (form.name.Equals(pf.name))
            {
                currentPlayerForm = pf.GetComponent <PlayerForm>();
            }
        }
        currentPlayerForm.gameObject.SetActive(true);
        currentPlayerForm.TeleportToPosition(pos);
        currentPlayerForm.FreezePosition(false);

        Camera.main.GetComponent <MyCamera>().target = currentPlayerForm.transform;

        // TODO: merge SwichForm functions into one
    }
Exemple #15
0
    private void FinishFormChange(PlayerForm form)
    {
        if (TransitionSprite.IsInsideTree())
        {
            RemoveChild(TransitionSprite);
        }

        string   nodeName = "Player" + PlayerNumber;
        NodePath nodePath = new NodePath(nodeName);

        Node formScene = CurrentScene.Instance();

        formScene.Name = nodeName;
        AddChild(formScene);

        Player newPlayerScript = GetNode <Player>(nodePath);

        FormChangeDelayTimer = 0;
        IsChangingForm       = false;

        string frameCacheKey = SpriteFolderName + "/" + CurrentForm.ToString();

        newPlayerScript.SetupPlayer(PlayerInputManager, PreviousTransform, PreviousVelocity, FrameCache[frameCacheKey], PreviousSpriteFlipped);
        CurrentPlayer = newPlayerScript;
    }
Exemple #16
0
 // performs all steps necessary to set an item once a valid position has been found
 void SetItem(Vector3 set_pos)
 {
     if (point_manager.UsePoints(heldItem.GetCost()))
     {
         heldItem.Set(set_pos);
         SFXManager.GetSFXManager().PlaySFX(SFX.BlockSet);
     }
     form = PlayerForm.Setting;
 }
Exemple #17
0
 public void PutPiece(int row, int column, PlayerForm player)
 {
     if (player.Equals(PlayerForm.Cross))
     {
         ///CPUプレーヤーの場合の番にユーザーが駒を配置しようとした場合は何もしない
         return;
     }
     model.PutPiece(row, column, player);
 }
Exemple #18
0
        /// <summary>
        /// ランダムに<see cref="playerForm"/>の駒を配置します
        /// </summary>
        /// <param name="player"></param>
        /// <param name="model"></param>
        public async void ChangedToMyTurn(PlayerForm player, ITicTacToeModel model)
        {
            await Task.Delay(TimeSpan.FromSeconds(1));

            int row;
            int column;

            (row, column) = VacantPosition(model, model.BoardSize);
            model.PutPiece(row, column, player);
        }
Exemple #19
0
 public void Play(VideoInfo video)
 {
     Width  = 0;
     Height = 0;
     info   = video;
     Initialize();
     form = new PlayerForm(this);
     form.Show();
     form.Play(video);
 }
Exemple #20
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var f         = new PlayerForm();
            var gameForm  = new GameForm(f);
            var presenter = new PlayerPresenter(f, gameForm);

            Application.Run(f);
        }
Exemple #21
0
 public AbilityDetails(AbilityDetails.AbilityType abilityType, AbilityDetails.PlayerForm playerForm,
                       Sprite abilityImage, string abilityName, string abilityDescription, float abilityCooldown)
 {
     this.abilityType        = abilityType;
     this.playerForm         = playerForm;
     this.abilityImage       = abilityImage;
     this.abilityName        = abilityName;
     this.abilityDescription = abilityDescription;
     this.abilityCooldown    = abilityCooldown;
 }
Exemple #22
0
        public void Play(VideoInfo video)
        {
            form = new PlayerForm(this);
            form.FilePosition += (v, position) =>
            {
                VideoInfoChange?.Invoke(v, position);
            };
            form.Show();

            form.Play(video);
        }
Exemple #23
0
    // when picking up an item, check to see if we have enough points to be able to
    // pick up the item in the first place
    void TryToHoldBlock(Collider2D itemCol)
    {
        Item itemScript = itemCol.GetComponent <Item> ();

        if (point_manager.UsePoints(itemScript.GetCost()))
        {
            itemScript.Attach(this);
            heldItem = itemScript;
            form     = PlayerForm.Setting;
        }
    }
Exemple #24
0
 public void Quit()
 {
     StopWatcher();
     info.ForceChange((long)(Time * 1000));
     VideoInfoChange?.Invoke(info, (long)(Time * 1000));
     if (_mpvHandle != IntPtr.Zero)
     {
         _mpvTerminateDestroy(_mpvHandle);
         _mpvHandle = IntPtr.Zero;
     }
     form = null;
 }
Exemple #25
0
    // used to release from a controllable block and update the correct attributes
    // Calling condition: user presses button to leave block or block is destroyed
    // called by: this.ControllingUpdate(release btn), Controllable.OnDestroy()
    public void DetachFromBlock()
    {
        sprend.color = Color.white;
        controlled_block.DetachUser();

        // JF: Re-enable tooltip
        controlled_block.image.enabled = true;

        controlled_block = null;
        form             = PlayerForm.Normal;
        SFXManager.GetSFXManager().PlaySFX(SFX.StopPilot);
    }
Exemple #26
0
 /// <summary>
 /// プレイヤーが衝突時
 /// </summary>
 /// <param name="arg_col"></param>
 private void OnTriggerEnter2D(Collider2D arg_col)
 {
     if (arg_col.tag == "Monster")
     {
         //プレイヤーを幽霊状態に移行
         m_playerForm = PlayerForm.Ghost;
         SoundPlayer.Instance.PlaySE("GhostSE");
     }
     if (arg_col.tag == "Paipu")
     {
         colPlayerOBject = arg_col.gameObject;
     }
 }
Exemple #27
0
        private void DemoFormItemOnOnExecute(object sender, EventArgs eventArgs)
        {
            if (_demoForm.IsDisposed)
            {
                _demoForm = new PlayerForm(Player, _hook);
            }

            var item = sender as IAimpMenuItem;

            Logger.Instance.AddInfoMessage($"Event: [Execute] {item.Id}");

            _demoForm.Show();
        }
Exemple #28
0
    /// <summary>
    /// コライダーと離れた際
    /// </summary>
    /// <param name="arg_col">Argument col.</param>
    private void OnTriggerExit2D(Collider2D arg_col)
    {
        //パイプと離れた
        if (arg_col.tag == "Paipu")
        {
            ExitCollider = true;
        }

        //壁をする抜けたら元の形態に戻る
        if (arg_col.tag == "PassWall")
        {
            m_playerForm = PlayerForm.Normal;
        }
    }
Exemple #29
0
        private void InitComponents()
        {
            Form             = new PlayerForm();
            statusController = new StatusController();
            actionController = new ActionController();

            InitConnectionPool();

            if (Config.Global.TcpSinkActive)
            {
                tcpSink = new TcpSink(Config.Global.TcpSinkPort); //, 3000);  // TODO B4RELEASE: remove timeout from TcpSink
                tcpSink.Activate();
            }
        }
Exemple #30
0
    void Start()
    {
        audioSource = GetComponent <AudioSource>();

        currentPlayerForm = GetComponentInChildren <PlayerForm>();

        playerForms = new List <Transform>();
        for (int i = 0; i < transform.childCount; ++i)
        {
            playerForms.Add(transform.GetChild(i));
        }

        Camera.main.GetComponent <MyCamera>().target = currentPlayerForm.transform;
    }
Exemple #31
0
        public static PlayerForm GetOpponentPlayerForm(this PlayerForm player)
        {
            var value = PlayerForm.None;

            switch (player)
            {
            case PlayerForm.Circle:
                value = PlayerForm.Cross;
                break;

            case PlayerForm.Cross:
                value = PlayerForm.Circle;
                break;
            }
            return(value);
        }
 public void ShowPlayer(PresentationInfo info)
 {
     using (PlayerForm player = new PlayerForm(info))
     {
         InitAndShowPlayer(player);
     }
     this.Show();
 }
 public static string GetPlayerFormName(PlayerForm form)
 {
     return (HM.Resources.Constants.EnumNames.PlayerFormNames[(int)form]);
 }
Exemple #34
0
        public void changePlayerTexture(KeyboardState currentKeyboardState)
        {
            // If player press 1, 2, etc. load new texture here...
            // if(input == 2) playerTexture = Content.Load<Texture2D>("PlayerTriangle");
            // if(input == 3) playerTexture = Content.Load<Texture2D>("PlayerCircle");
            // etc...

            if(currentKeyboardState.IsKeyDown(Keys.D1))
            {
                playerTexture = content.Load<Texture2D>("PlayerSquare");
                currentPlayerForm = PlayerForm.Square;
            }
            else if (currentKeyboardState.IsKeyDown(Keys.D2))
            {
                playerTexture = content.Load<Texture2D>("PlayerTriangle");
                currentPlayerForm = PlayerForm.Triangle;
            }
        }
    /*private IEnumerator UseItem()
    {
        IDictionary<string, object> testparam = new Dictionary<string, object>
        {
            { "itemname", "ShieldItem"},
            { "id", "822403307808270"}
        };
        ParseCloud.CallFunctionAsync<string>("UseItem", testparam).ContinueWith(t =>
        {
            rstext = t.Result;
            Debug.Log(rstext);
        });
        yield break;
    }*/
    void OnTriggerEnter2D(Collider2D col)
    {
        switch (col.tag) {
        case "EnemySquare":

            switch (playerform) {
            case (PlayerForm.Normal):
                playerEffect [2].Play ();
                gamestate.ChangeState(GameState.StateGame.Dying);//gamestate.stategame = GameState.StateGame.Dying;
                playerRigibody.AddForce (new Vector2 (0f, 600f));
                this.GetComponent<PolygonCollider2D> ().isTrigger = true;
                playerAnimator.SetBool ("die", true);
                Destroy (col.gameObject);
                break;

            case (PlayerForm.JumpForm):
                playerform = PlayerForm.Normal;
                playereffectObject.form = 0;
                jumpItem.PauseClock ();
                gamestate.ChangeState(GameState.StateGame.Restart);//gamestate.stategame = GameState.StateGame.Restart;
                break;

            case (PlayerForm.ShieldForm):
                Destroy (col.gameObject);
                break;

            case (PlayerForm.LifeForm):
                playerform = PlayerForm.Normal;
                playereffectObject.form = 0;
                gamestate.ChangeState(GameState.StateGame.Restart);//gamestate.stategame = GameState.StateGame.Restart;
                break;
            }
            break;

        case "Coin":
            playerEffect [3].Play ();
            resources.realgold += 1;
            break;
        case "ShieldItem":
            resources.numShieldItem += 1;
            if (FB.IsLoggedIn) {
                if (resources.HasConnection ())
                {
                    resources.AddItemCloud ("ShieldItem", 0);
                }
                else
                {
                    showNoConnection();
                }
            }
            Destroy (col.gameObject);
            break;
        case "JumpItem":
            resources.numJumpItem += 1;
            if (FB.IsLoggedIn) {
                if (resources.HasConnection ())
                {
                    resources.AddItemCloud ("JumpItem", 0);
                }
                else
                {
                    showNoConnection();
                }
            }
            Destroy (col.gameObject);
            break;
        case "LifeItem":
            resources.numLifeItem += 1;
            if (FB.IsLoggedIn) {
                if (resources.HasConnection ())
                {
                    resources.AddItemCloud ("LifeItem", 0);
                }
                else
                {
                    showNoConnection();
                }
            }
            Destroy (col.gameObject);
            break;

        }
    }
    // Use this for initialization
    void Start()
    {
        playerEffect = GetComponents<AudioSource>();
        playerEffect [0].Play ();
        playerEffect [0].loop = true;
        gamestate.ChangeState(GameState.StateGame.MainMenu);//gamestate.stategame = GameState.StateGame.MainMenu;
        playerRigibody = GetComponent <Rigidbody2D> ();
        playerAnimator = GetComponent <Animator> ();
        positionx = transform.position.x;
        realscore = 0;
        score = 0;
        playerform = PlayerForm.Normal;

        //StartCoroutine (GetAdsID());
    }
    // Update is called once per frame
    void Update()
    {
        if (score < resources.realgold)
            score += 1;
        if (resources.realgold == 0)
            score = 0;
        //balance.text = "Balance : " + score;
        coinText.text=resources.gold.ToString();
        if (gamestate.stategame == GameState.StateGame.Reborn)
        {
            Reborn();
        }
        if (gamestate.stategame == GameState.StateGame.Restart)
        {
            Restart();
        }

        transform.position = new Vector3 (positionx, transform.position.y, 0);

        //Xử lý gameState
        switch (gamestate.stategame)
        {

        /////////////////////////////Update MainMenu ////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////

        case GameState.StateGame.MainMenu:
            playerAnimator.SetFloat ("speed", 1f);
            break;

        //////////////////////////////Update InGame /////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////

        case GameState.StateGame.InGame:
            playerAnimator.SetFloat ("speed", 1f);

            // Xử lý Input mouse
            if (Input.GetMouseButtonDown(0)&&canJump==true)
            {
                Vector3 position = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Vector2 touchPos = new Vector2(position.x, position.y);
                RaycastHit2D hit = Physics2D.Raycast(touchPos, Vector2.up,0.001f,layerMask);
                if(hit)
                {
                    if(hit.collider.tag=="Shield"&&resources.numShieldItem>0)
                    {
                        //resources.numShieldItem-=1;
                        //shieldItem.StartCountdown();
                        //playereffectObject.form=1;
                        //jumpItem.PauseClock();
                        SaveDataCloud("Shield");
                    }
                    else if(hit.collider.tag=="Jump"&&resources.numJumpItem>0)
                    {
                        //resources.numJumpItem-=1;
                        //jumpItem.StartCountdown();
                        //playereffectObject.form = 2;
                        //shieldItem.PauseClock();
                        SaveDataCloud("Jump");
                    }
                    else if(hit.collider.tag=="Life"&&resources.numLifeItem>0)
                    {
                        //resources.numLifeItem-=1;
                        //playereffectObject.form = 3;
                        SaveDataCloud("Life");
                    }
                    //resources.SaveGame();

                }
                else if(!resources.isnotify)
                {
                    if(playerform==PlayerForm.JumpForm)
                    {
                        playerEffect[1].Play();
                        playerRigibody.AddForce(new Vector2(0f, 1000f));
                    }
                    else
                    {
                        playerEffect[1].Play();
                        playerRigibody.AddForce(new Vector2(0f, 500f));
                    }
                }
            }

            //Xử lý touch
            /*if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began&&canJump==true)
            {
                Vector3 position = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
                Vector2 touchPos = new Vector2(position.x, position.y);
                RaycastHit2D hit = Physics2D.Raycast(touchPos, Vector2.up,0.001f,layerMask);
                if(hit)
                {
                    if(hit.collider.tag=="Shield"&&resources.numShieldItem>0)
                    {
                        resources.numShieldItem-=1;
                        shieldItem.StartCountdown();
                        playereffectObject.form=1;
                        jumpItem.PauseClock();
                        SaveDataCloud("ShieldItem");
                    }
                    else if(hit.collider.tag=="Jump"&&resources.numJumpItem>0)
                    {
                        resources.numJumpItem-=1;
                        jumpItem.StartCountdown();
                        playereffectObject.form = 2;
                        shieldItem.PauseClock();
                    }
                    else if(hit.collider.tag=="Life"&&resources.numLifeItem>0)
                    {
                        resources.numLifeItem-=1;
                        playereffectObject.form = 3;
                    }
                    //resources.SaveGame();

                }
                else
                {
                    if(playerform==PlayerForm.JumpForm)
                    {
                        playerEffect[1].Play();
                        playerRigibody.AddForce(new Vector2(0f, 1000f));
                    }
                    else
                    {
                        playerEffect[1].Play();
                        playerRigibody.AddForce(new Vector2(0f, 500f));
                    }
                }
            }*/

            if (Input.GetKeyDown (KeyCode.Space)&& canJump==true)
            {

                if(playerform==PlayerForm.JumpForm)
                {
                    playerEffect[1].Play();
                    playerRigibody.AddForce(new Vector2(0f, 1000f));
                }
                else
                {
                    playerEffect[1].Play();
                    playerRigibody.AddForce(new Vector2(0f, 500f));
                }
            }
            break;

        /////////////////////////////Update EndGame /////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////
        }

        switch (playereffectObject.form)
        {
        case 0:
            playerform = PlayerForm.Normal;
            break;
        case 1:
            playerform = PlayerForm.ShieldForm;
            break;
        case 2:
            playerform = PlayerForm.JumpForm;
            break;
        case 3:
            playerform = PlayerForm.LifeForm;
            break;
        }

        /*
        //Xử lý key input di chuyển trái, phải
        float move = Input.GetAxisRaw ("Horizontal");
        //playerAnimator.SetFloat ("speed", Mathf.Abs(move));
        playerRigibody.velocity = new Vector2 (move*Time.deltaTime*200, playerRigibody.velocity.y);
        if (facingRight == true && move < 0)
        {
            facingRight = false;
            transform.rotation = Quaternion.Euler(transform.rotation.x,180,transform.rotation.z);
        }
        if (facingRight == false && move > 0)
        {
            facingRight = true;
            transform.rotation = Quaternion.Euler(transform.rotation.x,0,transform.rotation.z);
        }*/

        if (transform.position.y < -10&&gamestate.stategame!=GameState.StateGame.Shopping&&gamestate.stategame!=GameState.StateGame.HighScore)
        {
            //realscore = 0;
            gamestate.ChangeState(GameState.StateGame.EndScreen);//gamestate.stategame = GameState.StateGame.EndScreen;
            this.GetComponent<Rigidbody2D>().isKinematic = true;
            //resources.SaveGame();
        }
    }
 private void InitAndShowPlayer(PlayerForm player)
 {
     Cursor = Cursors.WaitCursor;
     player.InitPresentation();
     this.Hide();
     Cursor = Cursors.Default;
     player.ShowDialog();
 }