Example #1
0
        public void MoveTriggerImpl(Direction direction)
        {
            DirectionName = direction;
            List <string> PackedList = PackTilesToColection();

            MoveEngine moveEngine = new MoveEngine(PackedList, direction);

            UnpackColectionToTiles(moveEngine.MovedList);
            UpdateTilesBackgroundColors();
            TriggerFontSizeChange();

            int ScoreAfterMove = CalculateScoreBoard.CalculateScoreBoardMethod(PackTilesToColection());

            if (ScoreAfterMove > int.Parse(Score))
            {
                Score = ScoreAfterMove.ToString();
            }

            if (ScoreAfterMove > int.Parse(BestScore))
            {
                BestScore = ScoreAfterMove.ToString();
            }

            PackedList = PackTilesToColection();
            if (!PlayingOver2048)
            {
                if (CheckIfExist2048Tile(PackedList))
                {
                    var navigationParams = new NavigationParameters();
                    navigationParams.Add("ViewModel", this);

                    _navigationService.NavigateAsync("NavigationPage/WinningPopup", navigationParams);
                }
            }
        }
Example #2
0
 public AttackManager(Map gameMap)
 {
     this.gameMap    = gameMap;
     this.moveEngine = new MoveEngine
                       (
         gameMap: gameMap,
         OnCollision: (obj, collisionObj, moveVec) =>
     {
         BulletBomb((Bullet)obj, collisionObj);
         return(MoveEngine.AfterCollision.Destroyed);
     },
         EndMove: obj =>
     {
         GameObject.Debug(obj, " end move at " + obj.Position.ToString() + " At time: " + Environment.TickCount64);
         BulletBomb((Bullet)obj, null);
     },
         IgnoreCollision: (obj, collisionObj) =>
     {
         if (collisionObj is BirthPoint || collisionObj is Mine)
         {
             return(true);                                                                                           // 子弹不和出生点与地雷碰撞
         }
         return(false);
     }
                       );
 }
Example #3
0
 // Use this for initialization
 void Start()
 {
     moveEngine   = GetComponent <MoveEngine>();
     inputManager = GetComponent <InputManager>();
     collider     = GetComponent <Collider2D>();
     counter_life = 0;
     mainSlider   = GameObject.Find("LifeSlider").GetComponent <Slider>();
     slider_fill  = (GameObject.Find("SliderFill")).GetComponent <Image>();
     spirit       = Resources.Load("Prefabs/Spirit");
 }
Example #4
0
 // Use this for initialization
 void Start()
 {
     moveEngine   = GetComponent <MoveEngine>();
     dialogEngine = GetComponent <DialogueEngine>();
     transform    = GetComponent <Transform>();
     character    = GetComponent <Character>();
     collider     = GetComponent <Collider2D>();
     rb           = GetComponent <Rigidbody2D>();
     chase_mouse  = false;
 }
Example #5
0
 public void SetUp()
 {
     _mazeMock             = new Mock <IMaze>();
     _heroMock             = new Mock <IHero>();
     _roomMock             = new Mock <IRoom>();
     _complexModelBaseMock = new Mock <IComplexModelBase>();
     _roomMock.Setup(a => a.Content.ElementName).Returns(() => Keys.HeroKey);
     _mazeMock.Setup(a => a.GetEnumerable()).Returns(() => new List <IRoom>()
     {
         _roomMock.Object
     });
     _moveEngine = new MoveEngine(_heroMock.Object, _mazeMock.Object);
 }
Example #6
0
    void OnTriggerExit2D(Collider2D col)
    {
        if (col.gameObject.tag == ("Character"))
        {
            MoveEngine me = col.GetComponent <MoveEngine>();
            bool       b  = me.can_move;

            Character chara = col.GetComponent <Character>();
            bool      b2    = chara.is_player;

            if (b && !b2)
            {
                int r = Random.Range(1, 4);
                chara.direction = (Direction)(((int)(chara.direction) + r) % 4);
                chara.Change(chara.age, chara.direction);
            }
        }
    }
Example #7
0
 public PropManager(Map gameMap)
 {
     this.gameMap    = gameMap;
     this.moveEngine = new MoveEngine
                       (
         gameMap: gameMap,
         OnCollision: (obj, collisionObj, moveVec) =>
     {
         //越界,清除出游戏
         RemoveProp((Prop)obj);
         return(MoveEngine.AfterCollision.Destroyed);
     },
         EndMove: obj =>
     {
         GameObject.Debug(obj, " end move at " + obj.Position.ToString() + " At time: " + Environment.TickCount64);
     },
         IgnoreCollision: (obj, collisionObj) => true                                // 道具行动,一切皆忽略
                       );
     unpickedPropList     = new LinkedList <Prop>();
     unpickedPropListLock = new ReaderWriterLockSlim();
 }
Example #8
0
 public MoveManager(Map gameMap)
 {
     this.gameMap    = gameMap;
     this.moveEngine = new MoveEngine
                       (
         gameMap: gameMap,
         OnCollision: (obj, collisionObj, moveVec) =>
     {
         if (collisionObj is Mine)
         {
             ActivateMine((Character)obj, (Mine)collisionObj);
             return(MoveEngine.AfterCollision.ContinueCheck);
         }
         return(MoveEngine.AfterCollision.MoveMax);
     },
         EndMove: obj =>
     {
         GameObject.Debug(obj, " end move at " + obj.Position.ToString() + " At time: " + Environment.TickCount64);
     },
         IgnoreCollision: (obj, collisionObj) =>
     {
         if (collisionObj is BirthPoint)                                     // 自己的出生点可以忽略碰撞
         {
             if (object.ReferenceEquals(((BirthPoint)collisionObj).Parent, obj))
             {
                 return(true);
             }
             return(false);
         }
         else if (collisionObj is Mine)                                      // 自己队的炸弹忽略碰撞
         {
             if (((Mine)collisionObj).Parent.TeamID == ((Character)obj).TeamID)
             {
                 return(true);
             }
         }
         return(false);
     }
                       );
 }
Example #9
0
    public void switch_corpse(Character other)
    {
        if (is_young_enough() && !has_dialogue)
        {
            MoveEngine   other_move_engine   = other.GetComponent <MoveEngine>();
            InputManager other_input_manager = other.GetComponent <InputManager>();
            Collider2D   other_collider      = other.GetComponent <Collider2D>();

            other.is_player = false;
            other_move_engine.move(Vector2.zero);
            other_move_engine.can_move      = false;
            other_input_manager.chase_mouse = false;
            other_collider.isTrigger        = true;
            moveEngine.move(Vector2.zero);
            moveEngine.can_move = false;
            // TODO : launch animation
            GameObject spirit_orb = Instantiate(spirit) as GameObject;
            spirit_orb.GetComponent <SpiritTravel>().initialize(other.transform.position, transform.position, animation_time);
            //
            SoundEffects.Play("possession");
            Invoke("set_active_player", animation_time);
        }
    }
Example #10
0
 // Use this for initialization
 void Start()
 {
     moveEngine  = GetComponent <MoveEngine>();
     transform   = GetComponent <Transform>();
     chase_mouse = false;
 }
Example #11
0
 void OnDisable()
 {
     _engine = null;
 }
Example #12
0
 void OnEnable()
 {
     _engine = new MoveEngine(this);
 }