Esempio n. 1
0
        //Thread thread = new Thread(Console.Beep);

        public void MakeВeliberateAction(ref GameRoom level, int frameTime)
        {
            for (int i = 0; i <= level.lastObjectIndex; i++)
            {
                if (level.gameObj[i].IsActive)
                {
                    if (frameTime % level.gameObj[i].Slowness == 0)
                    {
                        MakeВeliberateAction(ref level, ref level.gameObj[i]);
                    }
                }
            }

            level.gameObj[level.FindPlayerIndex()].Action = UnitActions.None;
        }
        public GameRoom Init()
        {
            GameRoom level_1 = new GameRoom();

            level_1.CreateLevelStorage();

            CharacterConstructor characterConstructor = new CharacterConstructor();
            GameObject           player = characterConstructor.CreatePlayer(10, 30);

            level_1.AddGameObject(player);
            level_1.AddGameObject(characterConstructor.CreateBlindBeagle(12, 16));
            level_1.AddGameObject(characterConstructor.CreateBlindBeagle(30, 16));
            level_1.AddGameObject(characterConstructor.CreateBlindBeagle(50, 16));

            level_1.AddMap(new MapConstructor().Tutorial_1());

            return(level_1);
        }
Esempio n. 3
0
 public void Review(ref GameRoom room)
 {
     for (int i = 0; i <= room.lastObjectIndex; i++)
     {
         int collisionObgIndex;
         if (new CollisionChecker().CheckCollision(room, room.gameObj[i], out collisionObgIndex))
         {
             //PositionCl.GetBackPos(ref room.gameObj[i]); // если столкнулись, то движущияся обьект должен упереться в него
             new CollisionJudge().MakeDecision(ref room, ref room.gameObj[i], ref room.gameObj[collisionObgIndex]);
             new ActionMaker().MakeAction(ref room, ref room.gameObj[i]);
             new ActionMaker().MakeAction(ref room, ref room.gameObj[collisionObgIndex]);
             PositionCl.GetBackPos(ref room.gameObj[i]); // если столкнулись, то движущияся обьект должен упереться в него
         }
         else
         {
             //room.gameObj[i].Action = UnitActions.None;
         }
     }
 }
Esempio n. 4
0
        public void MakeDecision(ref GameRoom room, ref GameObject moovingObj, ref GameObject victimObj)
        {
            if (moovingObj.IsActive)
            {
                switch (moovingObj.ObjTag)
                {
                case Tags.None:
                    break;

                case Tags.Player:
                    break;

                case Tags.DamageToucher:
                    break;

                case Tags.Stone:
                    break;

                case Tags.BlindBeagle:
                    if (victimObj.ObjTag == Tags.Player)
                    {
                        victimObj.Action = UnitActions.Die;
                    }
                    break;

                case Tags.Bullet:
                    if (victimObj.ObjTag == Tags.BlindBeagle)
                    {
                        victimObj.Action = UnitActions.Die;
                    }
                    room.gameObj[moovingObj.Index].Action = UnitActions.Die;
                    break;

                case Tags.Zone:
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 5
0
        private UnitActions BlindBeagle(GameRoom level, GameObject beagle)
        {
            UnitActions beagleAction = UnitActions.None;

            if (beagle.IsActive)
            {
                int        playerIndex  = level.FindPlayerIndex();
                Coordinate playerCenter = level.gameObj[playerIndex].ObjArea.GetCenter();
                Coordinate beagleCenter = beagle.ObjArea.GetCenter();

                int absX = Math.Abs(playerCenter.x - beagleCenter.x);
                int absY = Math.Abs(playerCenter.y - beagleCenter.y);

                if (absX > absY)
                {
                    if (playerCenter.x >= beagleCenter.x)
                    {
                        beagleAction = UnitActions.MoveRight;
                    }
                    else
                    {
                        beagleAction = UnitActions.MoveLeft;
                    }
                }
                else
                {
                    if (playerCenter.y >= beagleCenter.y)
                    {
                        beagleAction = UnitActions.MoveDown;
                    }
                    else
                    {
                        beagleAction = UnitActions.MoveTop;
                    }
                }
            }
            return(beagleAction);
        }
Esempio n. 6
0
        public void MakeDecision(GameRoom level, ref GameObject thinkingObject, Direction dir = Direction.None)
        {
            UnitActions action = UnitActions.None;

            if (thinkingObject.IsActive)
            {
                switch (thinkingObject.ObjTag)
                {
                case Tags.Player:
                    action = thinkingObject.Action;
                    break;

                case Tags.DamageToucher:
                case Tags.Stone:
                    action = UnitActions.None;
                    break;

                case Tags.BlindBeagle:
                    action = BlindBeagle(level, thinkingObject);
                    break;

                case Tags.Bullet:
                    action = Bullet(thinkingObject, dir);
                    break;

                case Tags.Zone:
                    break;

                default:
                case Tags.None:
                    //TODO: Add log about error
                    break;
                }
            }

            thinkingObject.Action = action;
        }
Esempio n. 7
0
 public void SetPlayerDecision(GameRoom level, UnitActions action)
 {
     level.gameObj[level.FindPlayerIndex()].Action = action;
 }
Esempio n. 8
0
 public void Die(ref GameRoom room, GameObject dyingObj)
 {
     room.DeleteGameObject(dyingObj);
     UI.Hide(room.gameObj[dyingObj.Index]);
 }
Esempio n. 9
0
        public void MakeAction(ref GameRoom level, ref GameObject gameObject)
        {
            if (gameObject.IsActive)
            {
                switch (gameObject.Action)
                {
                case UnitActions.MoveRight:
                    PositionCl.Move(ref level, ref gameObject, Direction.Right);
                    break;

                case UnitActions.MoveLeft:
                    PositionCl.Move(ref level, ref gameObject, Direction.Left);
                    break;

                case UnitActions.MoveDown:
                    PositionCl.Move(ref level, ref gameObject, Direction.Down);
                    break;

                case UnitActions.MoveTop:
                    PositionCl.Move(ref level, ref gameObject, Direction.Top);
                    break;

                case UnitActions.Stop:
                    break;

                case UnitActions.ShootLeft:
                    Console.Beep(800, 50);
                    gameObject.Shoot(ref level, Direction.Left);
                    break;

                case UnitActions.ShootRight:
                    gameObject.Shoot(ref level, Direction.Right);
                    Console.Beep(800, 50);
                    break;

                case UnitActions.ShootDown:
                    gameObject.Shoot(ref level, Direction.Down);
                    Console.Beep(800, 50);
                    break;

                case UnitActions.ShootUp:
                    gameObject.Shoot(ref level, Direction.Top);
                    Console.Beep(800, 50);
                    break;

                case UnitActions.Die:
                    Die(ref level, gameObject);
                    break;

                case UnitActions.GetDamage:
                    break;

                case UnitActions.Attack:
                    break;

                default:
                case UnitActions.None:

                    break;
                }
            }
        }
Esempio n. 10
0
        public void MakeВeliberateAction(ref GameRoom level, ref GameObject gameObject)
        {
            new Brain().MakeDecision(level, ref gameObject);

            MakeAction(ref level, ref gameObject);
        }