Пример #1
0
 private List<IntVector> GetVector(IntVector vector)
 {
     int x = vector.X;
     int y = vector.Y;
     var vectors = new List<IntVector>();
     if (x + 1 < GameConfig.WidthX)
     {
         vectors.Add(new IntVector(vector.X + 1, vector.Y));
     }
     if (x - 1 > 0)
     {
         vectors.Add(new IntVector(vector.X - 1, vector.Y));
     }
     if (y + 1 < GameConfig.HightY)
     {
         vectors.Add(new IntVector(vector.X, vector.Y + 1));
     }
     if (y - 1 > 0)
     {
         vectors.Add(new IntVector(vector.X, vector.Y - 1));
     }
     vectors.Add(new IntVector(vector.X, vector.Y));
     int i = Control.SharedControl().GetRandom(vectors.Count);
     var value = new List<IntVector>();
     value.Add(vectors[i]);
     vectors.Remove(vectors[i]);
     i = Control.SharedControl().GetRandom(vectors.Count);
     value.Add(vectors[i]);
     return value;
 }
Пример #2
0
 public RevolutionAnchor(IntVector vector)
 {
     Wires = new List<Wire>();
     Sprite = MGSprite.MGSpriteWithFilename("point");
     WireShowLayer.SharedWireShow().AddChild(this);
     Vector = vector;
     Sprite.Position = Vector.ToUIVector2();
 }
Пример #3
0
 public virtual void SetVector(int x, int y)
 {
     Vector = new IntVector(x, y);
     if (Sprite != null)
     {
         Sprite.Position = Vector.ToUIVector2() + new Vector2(10, 16);
     }
 }
Пример #4
0
 public void Run()
 {
     this.Sprite.RunAction(MGRepeatForever.Actions(RunAni));
     Vector = new IntVector(GameConfig.WidthX - 1, _y);
     AtVector = new IntVector(GameConfig.WidthX, _y);
     var wire = WireShowLayer.SharedWireShow().WireDictionary[Vector];
     var fist = wire.Vector.ToUIVector2() + new Vector2(GameConfig.GirdSize / 2f, GameConfig.GirdSize / 2f);
     float t = Vector2.Distance(fist, Position) / 94f * 3.5f;
     this.RunAction(MGSequence.Actions(MGMoveTo.ActionWithDuration(t, fist), MGCallFunc.ActionWithTarget(() =>
     {
         FindPath(wire);
     })));
 }
Пример #5
0
        public void FindPath(Wire wire)
        {
            AtVector = Vector;
            if (wire.WireState != WireType.Wirei)
            {
                switch (ComeDirection)
                {
                    case WireDirection.WireRight:
                        #region Right
                        {
                            if (wire.WireData[3] != 0)
                            {
                                if (wire.WireData[1] == 0)
                                {
                                    if (wire.WireData[0] != 0 && wire.WireData[2] != 0)
                                    {
                                        if (Vector.Y < GameConfig.HightY / 2f)
                                        {
                                            ComeDirection = WireDirection.WireDown;
                                            GoDirection = WireDirection.WireUp;
                                        }
                                        else
                                        {
                                            ComeDirection = WireDirection.WireUp;
                                            GoDirection = WireDirection.WireDown;
                                        }
                                    }
                                    else
                                    {
                                        if (wire.WireData[0] != 0)
                                        {
                                            ComeDirection = WireDirection.WireDown;
                                            GoDirection = WireDirection.WireUp;
                                            if (wire.Vector.Y == GameConfig.HightY - 1)
                                            {
                                                ComeDirection = WireDirection.WireRight;
                                                GoDirection = WireDirection.WireLeft;
                                            }
                                        }
                                        if (wire.WireData[2] != 0)
                                        {
                                            ComeDirection = WireDirection.WireUp;
                                            GoDirection = WireDirection.WireDown;
                                            if (wire.Vector.Y == 0)
                                            {
                                                ComeDirection = WireDirection.WireRight;
                                                GoDirection = WireDirection.WireLeft;
                                            }
                                        }
                                    }

                                }
                                else
                                {
                                    ComeDirection = WireDirection.WireRight;
                                    GoDirection = WireDirection.WireLeft;
                                }
                            }
                            else
                            {
                                ComeDirection = WireDirection.WireRight;
                                GoDirection = WireDirection.WireLeft;
                            }
                        }
                        #endregion
                        break;
                    case WireDirection.WireLeft:
                        #region Left
                        {
                            if (wire.WireData[1] != 0)
                            {
                                if (wire.WireData[0] != 0 && wire.WireData[2] != 0)
                                {
                                    if (Vector.Y > GameConfig.HightY / 2f)
                                    {
                                        ComeDirection = WireDirection.WireDown;
                                        GoDirection = WireDirection.WireUp;
                                    }
                                    else
                                    {
                                        ComeDirection = WireDirection.WireUp;
                                        GoDirection = WireDirection.WireDown;
                                    }
                                }
                                else
                                {
                                    if (wire.WireData[0] != 0)
                                    {
                                        ComeDirection = WireDirection.WireDown;
                                        GoDirection = WireDirection.WireUp;
                                    }
                                    if (wire.WireData[2] != 0)
                                    {
                                        ComeDirection = WireDirection.WireUp;
                                        GoDirection = WireDirection.WireDown;
                                    }
                                }
                                //else
                                //{
                                //    ComeDirection = WireDirection.WireLeft;
                                //    GoDirection = WireDirection.WireRight;
                                //}
                            }
                            else
                            {
                                ComeDirection = WireDirection.WireRight;
                                GoDirection = WireDirection.WireLeft;
                            }
                        }
                        #endregion
                        break;
                    case WireDirection.WireUp:
                        #region Up
                        {
                            if (wire.WireData[1] != 0)
                            {
                                GoDirection = WireDirection.WireLeft;
                                ComeDirection = WireDirection.WireRight;
                            }
                            else
                            {
                                if (wire.WireData[2] != 0)
                                {
                                    GoDirection = WireDirection.WireDown;
                                    ComeDirection = WireDirection.WireUp;
                                }
                                else
                                {
                                    if (wire.WireData[3] != 0)
                                    {
                                        GoDirection = WireDirection.WireRight;
                                        ComeDirection = WireDirection.WireLeft;
                                    }
                                    else
                                    {
                                        GoDirection = WireDirection.WireLeft;
                                        ComeDirection = WireDirection.WireRight;
                                    }
                                }
                            }
                        }
                        #endregion
                        break;
                    case WireDirection.WireDown:
                        #region Down
                        {
                            if (wire.WireData[1] != 0)
                            {
                                ComeDirection = WireDirection.WireRight;
                                GoDirection = WireDirection.WireLeft;
                            }
                            else
                            {
                                if (wire.WireData[0] != 0)
                                {
                                    GoDirection = WireDirection.WireUp;
                                    ComeDirection = WireDirection.WireDown;
                                }
                                else
                                {
                                    if (wire.WireData[3] != 0)
                                    {
                                        GoDirection = WireDirection.WireRight;
                                        ComeDirection = WireDirection.WireLeft;
                                    }
                                    else
                                    {
                                        ComeDirection = WireDirection.WireRight;
                                        GoDirection = WireDirection.WireLeft;
                                    }
                                }
                            }
                        }
                        #endregion
                        break;
                }
            }
            else
            {
                ComeDirection = WireDirection.WireRight;
                GoDirection = WireDirection.WireLeft;
            }
            switch (GoDirection)
            {
                case WireDirection.WireUp:
                    Vector = new IntVector(Vector.X, Vector.Y + 1);
                    break;
                case WireDirection.WireLeft:
                    Vector = new IntVector(Vector.X - 1, Vector.Y);
                    break;
                case WireDirection.WireRight:
                    Vector = new IntVector(Vector.X + 1, Vector.Y);
                    break;
                case WireDirection.WireDown:
                    Vector = new IntVector(Vector.X, Vector.Y - 1);
                    break;
            }
            if (Vector.X > GameConfig.WidthX - 1)
            {
                Vector = new IntVector(GameConfig.WidthX - 1, Vector.Y);
                GoDirection = WireDirection.WireLeft;
                ComeDirection = WireDirection.WireRight;
            }
            if (Vector.X < 0)
            {
                //Vector = new IntVector(0, Vector.Y);
                GoDirection = WireDirection.WireLeft;
                ComeDirection = WireDirection.WireRight;

                var f = Vector.ToUIVector2() + new Vector2(GameConfig.GirdSize / 2f, GameConfig.GirdSize / 2f);
                this.RunAction(MGSequence.Actions(MGMoveTo.ActionWithDuration(3, f), MGCallFunc.ActionWithTarget(() =>
                {
                    //todo: GameOver
                    if (_islive)
                    {
                        //if (TeachingScene.ShardMainGame().IsTeaching)
                        //{
                        //    TeachingScene.ShardMainGame().IsTeaching = false;
                        //    TeachingScene.ShardMainGame().RunAction(MGSequence.Actions(MGJumpBy.ActionWithDuration(.8f, new Vector2(0, 10), 10, 7), MGCallFunc.ActionWithTarget(() =>
                        //    {
                        //        TeachingScene.ShardMainGame().Position = new Vector2();
                        //        Control.SharedControl().ReplaceScene(Control.SceneType.GameOverSceneType);
                        //    })));
                        //}
                        //else
                        {
                            if (CardShowLayer.SharedCardShow() == null)
                            {
                                MainGameScene.ShardMainGame().RunAction(MGSequence.Actions(MGJumpBy.ActionWithDuration(.8f, new Vector2(0, 10), 10, 7), MGCallFunc.ActionWithTarget(() =>
                                {
                                    MainGameScene.ShardMainGame().Position = new Vector2();
                                    Control.SharedControl().ReplaceScene(Control.SceneType.GameOverSceneType);
                                })));
                            }
                            else
                            {
                                if (!CardShowLayer.SharedCardShow().IsHas[Vector.Y])
                                {
                                    MainGameScene.ShardMainGame().RunAction(MGSequence.Actions(MGJumpBy.ActionWithDuration(1, new Vector2(0, 10), 10, 10), MGCallFunc.ActionWithTarget(() =>
                                    {
                                        MainGameScene.ShardMainGame().Position = new Vector2();
                                        Control.SharedControl().ReplaceScene(Control.SceneType.GameOverSceneType);
                                    })));
                                }
                            }
                        }

                    }
                    //var actor = new Actor();
                    //ZombieShowLayer.SharedZombieShow().AddChild(actor);
                    //actor.Run();
                })));
                return;
            }
            if (Vector.Y > GameConfig.HightY - 1)
            {
                Vector = new IntVector(Vector.X, Vector.Y - 1);
                GoDirection = WireDirection.WireLeft;
                ComeDirection = WireDirection.WireRight;
            }
            if (Vector.Y < 0)
            {
                Vector = new IntVector(Vector.X, 0);
                GoDirection = WireDirection.WireLeft;
                ComeDirection = WireDirection.WireRight;
            }

            var w = WireShowLayer.SharedWireShow().WireDictionary[Vector];
            var fist = w.Vector.ToUIVector2() + new Vector2(GameConfig.GirdSize / 2f, GameConfig.GirdSize / 2f);
            float t = Vector2.Distance(fist, Position) / 94f * 3.5f;
            if (Speed == 0)
            {
                t = t / 2f;
            }
            else if (Speed == 2)
            {
                t = t * 1.5f;
            }
            this.RunAction(MGSequence.Actions(MGMoveTo.ActionWithDuration(t, fist), MGCallFunc.ActionWithTarget(() =>
            {
                FindPath(w);
            })));
        }