Ejemplo n.º 1
0
 public Guide(ZoomCircle zoomCircle)
 {
     this.ParentZoomCircle = zoomCircle;
     this.IsUpsideDown = false;
     this.CurrentState = GuideState.CLOSED;
     this.selectedInfoPanel = 0;
 }
Ejemplo n.º 2
0
        public void ChangeGuideStatus(GuideState state)
        {
            switch (mCurrentGuideState)
            {
            case GuideState.Gate:
                HideKey(KeyType.Arrow);
                HideKey(KeyType.MARU);
                HideKey(KeyType.BATU);
                HideKey(KeyType.L);
                break;

            case GuideState.List:
                HideKey(KeyType.Arrow);
                HideKey(KeyType.MARU);
                HideKey(KeyType.BATU);
                HideKey(KeyType.L);
                HideKey(KeyType.RS);
                break;

            case GuideState.Detail:
                HideKey(KeyType.Arrow);
                HideKey(KeyType.MARU);
                HideKey(KeyType.BATU);
                HideKey(KeyType.L);
                break;
            }
            mCurrentGuideState = state;
            switch (mCurrentGuideState)
            {
            case GuideState.Gate:
                ShowKey(KeyType.Arrow);
                ShowKey(KeyType.MARU);
                ShowKey(KeyType.BATU);
                ShowKey(KeyType.L);
                HideKey(KeyType.RS);
                break;

            case GuideState.List:
                ShowKey(KeyType.Arrow);
                ShowKey(KeyType.MARU);
                ShowKey(KeyType.BATU);
                ShowKey(KeyType.L);
                ShowKey(KeyType.RS);
                break;

            case GuideState.Detail:
                ShowKey(KeyType.Arrow);
                ShowKey(KeyType.MARU);
                ShowKey(KeyType.BATU);
                ShowKey(KeyType.L);
                break;

            case GuideState.Quiet:
                Hide();
                break;
            }
        }
Ejemplo n.º 3
0
 public void SoldCargo()
 {
     if (state == GuideState.DropCargo)
     {
         arrow.SetActive(false);
         cargoText.SetActive(false);
         onSellText.SetActive(true);
         state = GuideState.None;
         Invoke("HideSellText", 5f);
     }
 }
Ejemplo n.º 4
0
    public void EnteredHatchCollider()
    {
        if (state == GuideState.ToHatch)
        {
            state = GuideState.DropCargo;
            cargoText.SetActive(false);

            cargoText.SetActive(true);
            onPickupCargoText.SetActive(false);
        }
    }
Ejemplo n.º 5
0
 protected virtual void Exit()
 {
     _state = GuideState.exit;
     if (_parent != null)
     {
         _parent.RunNode();
     }
     else
     {
         //already root
     }
 }
Ejemplo n.º 6
0
    public void SetState(GuideState state)
    {
        _State = state;
        Debug.Log(_State);
        if (_State == GuideState.StartGuide)
        {
            UIManager.UIData uiData = UIManager.Instance.Open(UIID.Main);
            MainUI = uiData.UIObject;
        }
        else if (_State == GuideState.PutBox)
        {
            UIManager.Instance.ShowMessage("点击屏幕摆放猫盆");
        }
        else if (_State == GuideState.GotoStore)
        {
            UIManager.Instance.ShowMessage("前往商店购买猫粮");
            MainUI ui = MainUI.GetComponent <MainUI> ();
            ui.ShowStoreBtn();
        }
        else if (_State == GuideState.PutGoodies)
        {
            UIManager.Instance.ShowMessage("点击猫盆放置猫粮");
        }
        else if (_State == GuideState.GotoStorage)
        {
            UIManager.Instance.ShowMessage("前往仓库使用猫窝");
        }
        else if (_State == GuideState.PutCatHouse)
        {
            UIManager.Instance.ShowMessage("点击屏幕摆放猫窝");
        }
        else if (_State == GuideState.OK)
        {
            MainUI ui = MainUI.GetComponent <MainUI>();
            ui.ShowHandbookBtn();

            /*
             * SceneCat cat = MapSceneManager.Instance.CreateSceneCat (104, Vector3.zero, Quaternion.identity);
             * cat.thisT.localRotation = Quaternion.Euler (90, 0, 0);
             * cat.thisT.position = Vector3.zero;
             #if !UNITY_EDITOR
             * TangoManager.Instance.SceneUnit2ARUnit (cat);
             #endif*/
        }
    }
Ejemplo n.º 7
0
 protected virtual void Enter()
 {
     _state = GuideState.enter;
     GameInput.Log("guide node enter : " + name);
 }
Ejemplo n.º 8
0
 protected virtual void Exit()
 {
     _state = GuideState.exit;
     if(_parent!=null)
     {
         _parent.RunNode();
     }
     else
     {
         //already root
     }
 }
Ejemplo n.º 9
0
 protected virtual void Execute()
 {
     _state = GuideState.execute;
 }
Ejemplo n.º 10
0
        public void Update()
        {
            int calloutWidth = PlanktonPopulations.guideImagesRight[0].Width;
            int calloutHeight = PlanktonPopulations.guideImagesRight[0].Height;
            int openButtonWidth = PlanktonPopulations.OpenTabRightImage.Width; // both left and right tab images should be same width
            int calloutVerticalOffset = calloutHeight - Settings.CALLOUT_VERTICAL_ADJUST - (int)Settings.CIRCLE_RADIUS;
            int x_closed, x_open, x_current = 0;

            // Determine if we're too close to the right edge
            if (this.ParentZoomCircle.position.X > Settings.RESOLUTION_X - calloutWidth)
            {
                // We're too close; reflect callouts
                this.IsLeftward = true;
                x_open = -calloutWidth + (int)Settings.CIRCLE_RADIUS;                 // x-coordinate relative to circle center of where to draw callout texture when callout is open
                x_closed = Settings.CALLOUT_HORIZONTAL_ADJUST - (int)Settings.CIRCLE_RADIUS - Settings.CALLOUT_HORIZONTAL_HIDE;   // x-coordinate relative to circle center of where to draw callout texture when callout is closed
            }
            else
            {
                // We're not too close, draw callouts normally
                this.IsLeftward = false;
                x_open = (int)Settings.CIRCLE_RADIUS + 2 * (int)Settings.CIRCLE_BORDER_WIDTH + Settings.CALLOUT_HORIZONTAL_HIDE;                                                           // x-coordinate relative to circle center of where to draw callout texture when callout is open
                x_closed = calloutWidth - (int)Settings.CIRCLE_RADIUS + Settings.CALLOUT_HORIZONTAL_HIDE + Settings.CALLOUT_HORIZONTAL_ADJUST;  // x-coordinate relative to circle center of where to draw callout texture when callout is closed
            }

            // Manage callout state, and calculate x-position of the callout source rectangle based on state and time since state began
            switch (this.CurrentState)
            {
                case GuideState.CLOSED:
                    x_current = x_closed;
                    break;
                case GuideState.OPENING:
                    float progress = (float)(PlanktonPopulations.gameTime.TotalGameTime.TotalMilliseconds - openingTime) / (float)Settings.CALLOUT_OPENING_TIME;
                    if (progress >= 1)
                    {
                        this.CurrentState = GuideState.OPEN;
                        x_current = x_open;
                    }
                    else
                    {
                        x_current = (int)MathHelper.SmoothStep(x_closed, x_open, progress);
                        //x = (int)((float)x - progress * (float)(x - LivingLiquid.CALLOUT_HORIZONTAL_HIDE));
                        //Debug.WriteLine(x);
                    }
                    break;
                case GuideState.OPEN:
                    x_current = x_open;
                    break;
                case GuideState.CLOSING:
                    float close_progress = (float)(PlanktonPopulations.gameTime.TotalGameTime.TotalMilliseconds - closingTime) / (float)Settings.CALLOUT_CLOSING_TIME;
                    if (close_progress >= 1)
                    {
                        this.CurrentState = GuideState.CLOSED;
                        x_current = x_closed;
                        //selectedInfoPanel = 5; // Show "open guide" tab
                        this.IsUpsideDown = false;
                    }
                    else
                    {
                        x_current = (int)MathHelper.SmoothStep(x_open, x_closed, close_progress);
                        //x = (int)((float)x - progress * (float)(x - LivingLiquid.CALLOUT_HORIZONTAL_HIDE));
                        //Debug.WriteLine(x);
                    }
                    break;
            }

            // Create a callout texture with the circle cut out
            GraphicsDevice graphicsDevice = PlanktonPopulations.graphicsDeviceManager.GraphicsDevice;
            renderTarget = new RenderTarget2D(graphicsDevice, calloutWidth + openButtonWidth, calloutHeight);
            graphicsDevice.SetRenderTarget(renderTarget);
            graphicsDevice.Clear(Color.Transparent);
            PlanktonPopulations.spriteBatch.Begin();
            // DEBUG
            //this.IsUpsideDown = true;
            if (this.IsLeftward)
            {
                if (this.CurrentState != GuideState.CLOSED)
                {
                    if (this.IsUpsideDown)
                    {
                        PlanktonPopulations.spriteBatch.Draw(PlanktonPopulations.guideImagesRight[selectedInfoPanel], new Vector2(guideTabRightOffset.X, Settings.CALLOUT_VERTICAL_ADJUST), null, Color.White, (float)Math.PI, new Vector2(calloutWidth, calloutHeight), 1f, SpriteEffects.None, 0f);
                    }
                    else
                    {
                        PlanktonPopulations.spriteBatch.Draw(PlanktonPopulations.guideImagesLeft[selectedInfoPanel], new Vector2(guideTabRightOffset.X, 0), Color.White);
                    }
                    PlanktonPopulations.spriteBatch.Draw(PlanktonPopulations.CloseTabLeftImage, guideTabLeftOffset, Color.White);
                    //PlanktonPopulations.spriteBatch.Draw(PlanktonPopulations.closeTabLeftImage, PlanktonPopulations.ArrowsOffset, Color.White);
                }
                else
                {
                    PlanktonPopulations.spriteBatch.Draw(PlanktonPopulations.OpenTabLeftImage, guideTabLeftOffset, Color.White);
                    //PlanktonPopulations.spriteBatch.Draw(PlanktonPopulations.openTabLeftImage, PlanktonPopulations.ArrowsOffset, Color.White);
                }
                PlanktonPopulations.spriteBatch.End();
                PlanktonPopulations.spriteBatch.Begin(SpriteSortMode.Deferred, PlanktonPopulations.subtractAlpha);
                PlanktonPopulations.spriteBatch.DrawCircle(new Vector2(-x_current + guideTabRightOffset.X, calloutVerticalOffset), Settings.CIRCLE_RADIUS, 64, Color.White, Settings.CIRCLE_RADIUS);
                PlanktonPopulations.spriteBatch.End();
                // Calculate source rectangle
                guideSourceRect = new Rectangle(0, 0, -Settings.CALLOUT_HORIZONTAL_HIDE - x_current, calloutHeight);
                // Position to draw callout
                guidePosition = new Vector2(this.ParentZoomCircle.position.X + x_current - guideTabRightOffset.X, this.ParentZoomCircle.position.Y - calloutVerticalOffset);
            }
            else
            {
                if (this.CurrentState != GuideState.CLOSED)
                {
                    if (this.IsUpsideDown)
                    {
                        PlanktonPopulations.spriteBatch.Draw(PlanktonPopulations.guideImagesLeft[selectedInfoPanel], new Vector2(0, Settings.CALLOUT_VERTICAL_ADJUST), null, Color.White, (float)Math.PI, new Vector2(calloutWidth, calloutHeight), 1f, SpriteEffects.None, 0f);
                    }
                    else
                    {
                        PlanktonPopulations.spriteBatch.Draw(PlanktonPopulations.guideImagesRight[selectedInfoPanel], Vector2.Zero, Color.White);
                    }
                    PlanktonPopulations.spriteBatch.Draw(PlanktonPopulations.CloseTabRightImage, new Vector2(PlanktonPopulations.guideImagesRight[selectedInfoPanel].Width - PlanktonPopulations.CloseTabRightImage.Width, 0f) + guideTabRightOffset, Color.White);
                    //PlanktonPopulations.spriteBatch.Draw(PlanktonPopulations.closeTabRightImage, new Vector2(PlanktonPopulations.guideImagesRight[selectedInfoPanel].Width - PlanktonPopulations.closeTabRightImage.Width, 0f) + PlanktonPopulations.ArrowsOffset, Color.White);
                }
                else
                {
                    PlanktonPopulations.spriteBatch.Draw(PlanktonPopulations.OpenTabRightImage, new Vector2(calloutWidth - PlanktonPopulations.OpenTabRightImage.Width, 0f) + guideTabRightOffset, Color.White);
                    //PlanktonPopulations.spriteBatch.Draw(PlanktonPopulations.openTabRightImage, new Vector2(calloutWidth - PlanktonPopulations.openTabRightImage.Width, 0f) + PlanktonPopulations.ArrowsOffset, Color.White);
                }
                PlanktonPopulations.spriteBatch.End();
                PlanktonPopulations.spriteBatch.Begin(SpriteSortMode.Deferred, PlanktonPopulations.subtractAlpha);
                PlanktonPopulations.spriteBatch.DrawCircle(new Vector2(x_current - Settings.CALLOUT_HORIZONTAL_HIDE, calloutVerticalOffset), Settings.CIRCLE_RADIUS, 64, Color.White, Settings.CIRCLE_RADIUS);
                PlanktonPopulations.spriteBatch.End();
                // Calculate source rectangle
                guideSourceRect = new Rectangle(x_current, 0, calloutWidth - x_current + openButtonWidth, calloutHeight);
                // Position to draw callout
                guidePosition = new Vector2(this.ParentZoomCircle.position.X + Settings.CALLOUT_HORIZONTAL_HIDE - 0 * Settings.CIRCLE_RADIUS, this.ParentZoomCircle.position.Y - calloutVerticalOffset);
            }
            graphicsDevice.SetRenderTarget(null);
            this.texture = (Texture2D)renderTarget;
        }
Ejemplo n.º 11
0
 public void OpenButtonPressed(bool upsideDown)
 {
     if (this.CurrentState == GuideState.CLOSED)
     {
         Debug.WriteLine("Open button pressed!");
         CurrentState = GuideState.OPENING;
         openingTime = PlanktonPopulations.gameTime.TotalGameTime.TotalMilliseconds;
         selectedInfoPanel = 0;
         this.IsUpsideDown = upsideDown;
         //this.upsideDownCallouts = true; // DEBUG
     }
 }
Ejemplo n.º 12
0
 protected virtual void Execute()
 {
     _state = GuideState.execute;
 }
Ejemplo n.º 13
0
 protected virtual void Enter()
 {
     _state = GuideState.enter;
     GameInput.Log("guide node enter : " + name);
 }
Ejemplo n.º 14
0
 private void HideSellText()
 {
     onSellText.SetActive(false);
     state = GuideState.Disabled;
 }
Ejemplo n.º 15
0
 public void CloseButtonPressed()
 {
     if (CurrentState == GuideState.OPEN)
     {
         Debug.WriteLine("Close button pressed!");
         CurrentState = GuideState.CLOSING;
         closingTime = PlanktonPopulations.gameTime.TotalGameTime.TotalMilliseconds;
     }
 }
Ejemplo n.º 16
0
    private void Update()
    {
        // Makeshift state machine for guiding the player first time starting
        if (state != GuideState.Disabled)
        {
            if (!player)
            {
                // If player dies, prevent errors by destroying guide system and setting the empty reference to this
                Destroy(gameObject);
                player = transform;
            }
            if (Input.GetKeyDown(KeyCode.H))
            {
                state = GuideState.Disabled;
                arrow.SetActive(false);
                cargoText.SetActive(false);
                startText.SetActive(false);
                onSellText.SetActive(false);
                onPickupCargoText.SetActive(false);
            }

            switch (state)
            {
            case GuideState.ToCargo:
                startText.SetActive(true);
                onPickupCargoText.SetActive(false);
                var cols = Physics2D.CircleCastAll(transform.position, radius, Vector2.down, 0, cargoLayer);
                if (cols.Length > 0)
                {
                    nearestCargo = NearestCargo(cols);
                    arrow.SetActive(true);
                    RotateArrow(nearestCargo.position);
                    //var hits = Physics2D.RaycastAll(transform.position, transform.up * -1, 2.0f, cargoLayer);

                    var hits = Physics2D.CircleCastAll(player.position, 2f, Vector2.zero, 0, cargoLayer);
                    foreach (var hit in hits)
                    {
                        if (hit.collider.CompareTag("Cargo"))
                        {
                            state = GuideState.ToHatch;
                        }
                    }
                }
                else
                {
                    arrow.SetActive(false);
                }
                transform.position = player.transform.position;
                break;

            case GuideState.ToHatch:

                if (!Physics2D.CircleCast(player.position, 2f, Vector2.zero, 0, cargoLayer))
                {
                    state = GuideState.ToCargo;
                }

                startText.SetActive(false);
                onPickupCargoText.SetActive(true);
                RotateArrow(hatch.position);
                transform.position = player.transform.position;
                break;

            case GuideState.DropCargo:
                arrow.SetActive(true);
                RotateArrow(hatch.position);
                transform.position = player.transform.position;
                break;

            case GuideState.None:
                transform.position = player.transform.position;
                arrow.SetActive(false);
                cargoText.SetActive(false);
                break;

            default:
                break;
            }
        }
    }
Ejemplo n.º 17
0
 void OnInit()
 {
     _State = GuideState.None;
 }