Beispiel #1
0
        public MainMenu(GameClass game)
            : base(game)
        {
            Background = new Image(game, @"Images\Screen_MainMenu");

            title = new Label(game, "Keepers of Otherness", "Cambria_72pt_b", Color.White);
            title.Rect = new Rectangle(Globals.ScreenCenterX - title.Rect.Width / 2, 100, title.Rect.Width, title.Rect.Height);
            Add(title);

            subtitle = new Label(game, "Book 1: DARKNESS WITHIN", "Cambria_30pt", Color.White);
            subtitle.Rect = new Rectangle(Globals.ScreenCenterX - subtitle.Rect.Width / 2, 100 + title.Rect.Height + 10, subtitle.Rect.Width, subtitle.Rect.Height);
            Add(subtitle);

            newGame = new Button(game, "New Game", "Cambria_18pt", Globals.ScreenCenterX - 90, Globals.ScreenHeight - 250, 180, 40);
            newGame.OnMouseClick = delegate(object sender, EventArgs e)
            {
                game.Screen_NewGame = new NewGame(game);
                game.currentScreen = GameScreen.NEW_GAME;
            };
            Add(newGame);

            loadGame = new Button(game, "Load Game", "Cambria_18pt", Globals.ScreenCenterX - 90, Globals.ScreenHeight - 250 + 10 + newGame.Rect.Height, 180, 40);
            Add(loadGame);

            settings = new Button(game, "Settings", "Cambria_18pt", Globals.ScreenCenterX - 90, Globals.ScreenHeight - 250 + 10 + newGame.Rect.Height + 10 + loadGame.Rect.Height, 180, 40);
            Add(settings);

            quit = new Button(game, "Exit", "Cambria_18pt", Globals.ScreenCenterX - 90, Globals.ScreenHeight - 250 + 10 + newGame.Rect.Height + 10 + loadGame.Rect.Height + 10 + settings.Rect.Height, 180, 40);
            quit.OnMouseClick = delegate(object sender, EventArgs e)
            {
                game.Exit();
            };
            Add(quit);
        }
Beispiel #2
0
 public Button(GameClass game, string text)
     : base(game)
 {
     init();
     label = new Label(game, text);
     Rect = new Rectangle(label.Rect.X, label.Rect.Y, label.Rect.Width, label.Rect.Height);
 }
Beispiel #3
0
        public Label(GameClass game)
            : base(game)
        {
            init();

            Font = Res.Get<SpriteFont>(@"Fonts\Cambria_12pt");
            FontColor = Color.Black;
        }
Beispiel #4
0
        public Button(GameClass game, string text, string fontFileTitle)
            : base(game)
        {
            init();

            _state = States.DEFAULT;
            label = new Label(game, text, fontFileTitle, Color.White);
            Rect = new Rectangle(label.Rect.X, label.Rect.Y, label.Rect.Width, label.Rect.Height);
        }
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {

            GameClass game = new GameClass();
            game.Run();



        }
Beispiel #6
0
        public TabbedPanel(GameClass game)
            : base(game)
        {
            Elements = new List<Tuple<TabbedPanelButton, Panel>>();
            SelectedIndex = 0;

            Visible = true;
            Enabled = true;

            DefaultTabs = true;
            NoSelectedTabsMode = false;
        }
Beispiel #7
0
        public Label(GameClass game, string text, int x, int y)
            : base(game)
        {
            init();

            Text = text;
            Font = Res.Get<SpriteFont>(@"Fonts\Cambria_12pt");
            FontColor = Color.Black;

            Vector2 labelSize = Font.MeasureString(Text);
            Rect = new Rectangle(x, y, (int)labelSize.X, (int)labelSize.Y);
        }
Beispiel #8
0
        public Label(GameClass game, string text, string fontFileTitle, Color fontColor, int x, int y)
            : base(game)
        {
            init();

            Text = text;
            Font = Res.Get<SpriteFont>(@"Fonts\" + fontFileTitle);
            FontColor = fontColor;

            Vector2 labelSize = Font.MeasureString(Text);
            Rect = new Rectangle(x, y, (int)labelSize.X, (int)labelSize.Y);
        }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GUIInterface"/> class.
 /// </summary>
 public GUIInterface()
 {
     game = new GameClass();
     game.HandCardClicked += HandCardToControl;
     game.SupplyCardClicked += SupplyAttemptToControl;
     game.EndPhaseClicked += EndPhaseToControl;
     game.StartUpdate += StartUpdateToControl;
     CardInHandPressed += HandPressed;
     BuyAttempt += SupplyPressed;
     EndPhasePressed += PhaseEndPressed;
     StartUpdate += UpdateHappened;
 }
Beispiel #10
0
        public Image(GameClass game, string fileName, bool external = false)
            : base(game)
        {
            Visible = true;
            FileName = fileName;

            if (external)
                LoadExternal(fileName);
            else
            {
                Texture = Res.Get<Texture2D>(fileName);
                Rect = Texture.Bounds;
            }
        }
Beispiel #11
0
        public void Form1Test()
        {
            GameClass game = new GameClass();
            int       y    = game.GenRandom();

            if (y > 10)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
Beispiel #12
0
        public void Form2Test()
        {
            GameClass game = new GameClass();
            int       y    = game.updateAmount(1, 1, 100, 20);

            if (y == 120)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
Beispiel #13
0
        static void Main(string[] args)
        {
            // define character classes in a list
            List <CharacterClassStats> ListOfCharacterClasses = CharacterBox.GetCharacters();

            // get user to choose class
            startgame :  Console.WriteLine("Choose your class");
            foreach (CharacterClassStats item in ListOfCharacterClasses)
            {
                Console.Write(item.Name + ", ");
            }

            // get player input and assign to PlayerCharacter variable
            string ClassChoice = Console.ReadLine();

            // ensure string starts with uppercase and follows with lowercase
            // for comparing

            ClassChoice = char.ToUpper(ClassChoice[0]) + ClassChoice.Substring(1).ToLower();

            // null the playercharacter to be able to get value out of foreach
            CharacterClassStats PlayerCharacter = null;

            foreach (CharacterClassStats item in ListOfCharacterClasses)
            {
                if (item.Name == ClassChoice)
                {
                    PlayerCharacter = item;
                    break;
                }
            }

            //clear the screen and start the game.
            Console.Clear();
            Console.WriteLine("--------------");
            Console.WriteLine("Tale of Legends: " + PlayerCharacter.Name);
            Console.WriteLine("--------------");
            Console.WriteLine($"HP: {PlayerCharacter.StartingHealth} | Level: {PlayerCharacter.Level}");
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("");

            GameClass Continue = new GameClass();

            Continue.ContinueGame();

            Console.WriteLine("Test Attack");
            Console.WriteLine(PlayerCharacter.AttackDamage(PlayerCharacter.Attacks, PlayerCharacter.MaxDamage));
        }
    public MainClass()
    {
        //display the splash screen and determine network status
        splash = new SplashScreen(this);
        splash.ShowDialog();

        try {
            game = new GameClass(fullScreen, gameFormSize, enableNetwork);
        }
        catch(DirectXException) {
            return;
        }
        if( game.CreateGraphicsSample() )
            game.Run();
    }
    private float waitCount = 6.0f; // wait count before state transition.

    #endregion Fields

    #region Constructors

    public Ship(Device device, GameClass gameClass, HullColors hullColor)
    {
        this.device = device;
        this.game = gameClass;
        shots = new Shots(device);
        if (hullColor == HullColors.White) {
            shipMesh = new PositionedMesh(device, "WhiteShip.x");
            startingPosition = new Vector3(10, 0, 10);
        }
        else {
            shipMesh = new PositionedMesh(device, "RedShip.x");
            startingPosition = new Vector3(-50, 0, -150);
        }
        SetRandomPosition(true);
    }
Beispiel #16
0
        public void Test_PlacePenguin()
        {
            GameClass game = new GameClass();

            game.AddPlayer("player1", PlayerType.AIMedium);
            game.AddPlayer("player2", PlayerType.AIMedium);
            game.ChoosePlayerColor();
            game.StartGame();

            game.AI_medium.PlacePenguin(game.Board, game.CurrentPlayer, game.AIPenguins);
            game.AI_medium.PlacePenguin(game.Board, game.CurrentPlayer, game.AIPenguins);

            foreach (Cell cell in game.Board.Board)
            {
            }
        }
Beispiel #17
0
    /*
     * Start():
     * called when the scene is loaded.
     * Puts all sectors into the graph sector_graph (stored as a dictionary);
     */
    void Start()
    {
        GameClass.init();
        foreach (Transform child in transform)
        {
            if (child.name.Substring(0, 8) == "Sector #")
            {
                Sector            sector           = child.GetComponent <Sector>();
                List <GameObject> adjacent_sectors = sector.AdjacentSectors;

                this.sector_graph.Add(child.gameObject, adjacent_sectors);
            }
        }
        this.assignSectorsToPlayers();
        this.colourSectors();
    }
Beispiel #18
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public MovimentosEnum IniciarValidacao()
        {
            MovimentosEnum movimento = GameClass.NextPositionValidation();

            if (movimento != MovimentosEnum.DISABLE)
            {
                Animation?.Start();

                if (GameState == Enums.Gameplay.GameStateEnum.Paused)
                {
                    Animation?.Pause();
                }
            }

            return(movimento);
        }
Beispiel #19
0
        public Button(GameClass game, string text, string fontFileTitle, int x, int y, int width = 0, int height = 0)
            : base(game)
        {
            init();

            if (width == 0) // absolute coordinates for the label
            {
                label = new Label(game, text, fontFileTitle, Color.White, x, y);
                Rect = new Rectangle(x, y, label.Rect.Width, label.Rect.Height);
            }
            else // relative coordinates for the label (in respect to the Button's Rect)
            {
                label = new Label(game, text, fontFileTitle, Color.White);
                Rect = new Rectangle(x, y, width, height);
            }
        }
Beispiel #20
0
        internal static long Part2(string input)
        {
            string[]   lines = input.Split('\n');
            PlayerDeck p1    = new PlayerDeck();
            PlayerDeck p2    = new PlayerDeck();

            bool playerone = true;

            foreach (string ln in lines)
            {
                if (int.TryParse(ln, out int v))
                {
                    if (playerone)
                    {
                        p1.cards.Enqueue(v);
                    }
                    else
                    {
                        p2.cards.Enqueue(v);
                    }
                }
                else if (ln == "")
                {
                    playerone = false;
                }
            }
            GameClass gc    = new GameClass(p1, int.MaxValue, p2, int.MaxValue);
            int       score = 0;

            if (gc.GetWinner())
            {
                //p1
                while (gc.p1.cards.Count > 0)
                {
                    score += gc.p1.cards.Count * gc.p1.cards.Dequeue();
                }
            }
            else
            {
                //p2
                while (gc.p2.cards.Count > 0)
                {
                    score += gc.p2.cards.Count * gc.p2.cards.Dequeue();
                }
            }
            return(score);
        }
Beispiel #21
0
        public void Test_GetAvailablePlacementCell()
        {
            GameClass game = new GameClass();

            game.AddPlayer("player1", PlayerType.AIEasy);
            game.AddPlayer("player2", PlayerType.AIEasy);
            game.ChoosePlayerColor();
            game.StartGame();

            List <Cell> cellList = game.AI_easy.GetAvailablePlacementCell((BoardClass)game.Board);

            foreach (Cell cell in cellList)
            {
                Assert.IsTrue(cell.CellType == CellType.Fish);
                Assert.IsTrue(cell.FishCount == 1);
            }
        }
Beispiel #22
0
 public Ship(Device device, GameClass gameClass, HullColors hullColor)
 {
     this.device = device;
     this.game   = gameClass;
     shots       = new Shots(device);
     if (hullColor == HullColors.White)
     {
         shipMesh         = new PositionedMesh(device, "WhiteShip.x");
         startingPosition = new Vector3(10, 0, 10);
     }
     else
     {
         shipMesh         = new PositionedMesh(device, "RedShip.x");
         startingPosition = new Vector3(-50, 0, -150);
     }
     SetRandomPosition(true);
 }
Beispiel #23
0
        public void Test_GetMyPenguinsCell()
        {
            GameClass game = new GameClass();

            game.AddPlayer("player1", PlayerType.AIEasy);
            game.AddPlayer("player2", PlayerType.AIEasy);
            game.ChoosePlayerColor();
            game.StartGame();

            List <Cell> cellList = game.AI_easy.GetMyPenguinsCell((BoardClass)game.Board, (PlayerClass)game.CurrentPlayer);

            foreach (Cell cell in cellList)
            {
                Assert.IsTrue(cell.CellType == CellType.FishWithPenguin);
                Assert.IsTrue(cell.CurrentPenguin.Player == game.CurrentPlayer);
            }
        }
Beispiel #24
0
    public MainClass()
    {
        //display the splash screen and determine network status
        splash = new SplashScreen(this);
        splash.ShowDialog();

        try {
            game = new GameClass(fullScreen, gameFormSize, enableNetwork);
        }
        catch (DirectXException) {
            return;
        }
        if (game.CreateGraphicsSample())
        {
            game.Run();
        }
    }
        public void Migrate()
        {
            var gameClasses = SourceDbContext.GameClasses.ToList();

            foreach (var gameClass in gameClasses)
            {
                var newEntity = new GameClass()
                {
                    Id     = _gameClassKeyMapper.MapKey(gameClass.Id),
                    Name   = gameClass.Name,
                    GameId = gameClass.GameId
                };

                TargetDbContext.GameClasses.Add(newEntity);
            }

            TargetDbContext.SaveChanges();
        }
        //==========================================================================
        //Map 100-199 (100 commands reserved or used for ) THESE ARE IN ORDER
        //==========================================================================
        void ChangeMap(string MapName, ref GameClass Game)
        {
            for (int i = 0; i < Game.MapHandler.Count; i++)
            {
                if (Game.MapHandler[i].getMapName() == (MapName + ".mxt"))
                {
                    Game.setCurrentMapIndex(i);
                    Game.Character.setCollissionMap(Game.MapHandler[Game.getCurrentMapIndex()].getCollisionMap());
                    Game.Character.RefineCollissionMap(Game.MapHandler[Game.getCurrentMapIndex()].getTileSize(),
                                                       Game.MapHandler[Game.getCurrentMapIndex()].getMaxTiles(),
                                                       Game.MapHandler[Game.getCurrentMapIndex()].getColCount(),
                                                       Game.MapHandler[Game.getCurrentMapIndex()].getRowCount());
                    break;
                }
            }

            Game.Redraw();
        }
Beispiel #27
0
        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            switch (reader.TokenType)
            {
            case JsonToken.String:
            case JsonToken.Date:
                string stringValue = serializer.Deserialize <string>(reader);
                return(new GameElement {
                    String = stringValue
                });

            case JsonToken.StartObject:
                GameClass objectValue = serializer.Deserialize <GameClass>(reader);
                return(new GameElement {
                    GameClass = objectValue
                });
            }
            throw new Exception("Cannot unmarshal type GameElement");
        }
    private float waitCount = 6.0f; // wait count before state transition.

    #endregion Fields

    #region Constructors

    public Ship(Device device, GameClass gameClass, HullColors hullColor)
    {
        this.device = device;
        this.game = gameClass;
        shots = new Shots(device);
        if (hullColor == HullColors.White) {
            shipMesh = new PositionedMesh(device, "WhiteShip.x");
            startingPosition = new Vector3(10, 0, 10);
        }
        else {
            shipMesh = new PositionedMesh(device, "RedShip.x");
            startingPosition = new Vector3(-50, 0, -150);
        }
        vaporTrail = new ParticleEffects(device);
        vaporTrail.ParticleTexture = TextureLoader.FromFile(device,
            MediaUtilities.FindFile("particle-blue.bmp"));

        SetRandomPosition(true);
    }
Beispiel #29
0
    private static TypeDefinition GetOrDumpType(IntPtr klass)
    {
        if (klass == IntPtr.Zero)
        {
            return(null);
        }
        GameClass    runtimeClass    = new GameClass(klass);
        GameAssembly runtimeAssembly = new GameAssembly(runtimeClass.Assembly);

        // Run assembly dump
        AssemblyDefinition assembly = DumpAssembly(runtimeAssembly);

        if (assembly == null)
        {
            return(null);
        }

        // Find and return type
        return(SearchType(assembly.MainModule.Types, runtimeClass));
    }
Beispiel #30
0
        public ActionResult Update(string guess, int gameid)
        {
            char      newGuess     = guess[0];
            bool      resultFound  = false;
            GameClass selectedGame = GameClass.Find(gameid);

            foreach (Letter candidate in selectedGame.Letters)
            {
                if (newGuess == candidate.LetterOfWord)
                {
                    candidate.Visible = true;
                    resultFound       = true;
                }
            }
            if (!resultFound)
            {
                selectedGame.FailsRemaining -= 1;
            }
            return(RedirectToAction("Show", gameid));
        }
    public PlayClass(GameClass parent)
    {
        this.parent = parent;
        this.peerObject = peerObject;
        this.message = new MessageDelegate(parent.MessageArrived);

        peerObject = new Peer();
        // First set up our event handlers (We only need events for the ones we care about)
        peerObject.PlayerCreated += new PlayerCreatedEventHandler(this.PlayerCreated);
        peerObject.PlayerDestroyed += new PlayerDestroyedEventHandler(this.PlayerDestroyed);
        peerObject.HostMigrated += new HostMigratedEventHandler(this.HostMigrated);
        peerObject.Receive += new ReceiveEventHandler(this.DataReceived);
        peerObject.SessionTerminated += new SessionTerminatedEventHandler(this.SessionTerminated);

        Connect = new ConnectWizard(peerObject, AppGuid, "Step2");
        if (!Connect.StartWizard()) {
            MessageBox.Show("DirectPlay initialization was incomplete. Application will terminate.");
            throw new DirectXException();
        }
    }
Beispiel #32
0
    public void setText(GameClass game)
    {
        Debug.Log("SETTEXT " + game.getHome() + " " + game.getAway());
        int val = Random.Range(game.getMargin() - 10, game.getMargin() + 10);

        side1.text = game.getHome() + "\n" + val;
        val        = Random.Range(game.getMargin() - 10, game.getMargin() + 10);
        side2.text = game.getHome() + "\n" + val;
        val        = Random.Range(game.getMargin() - 10, game.getMargin() + 10);
        side3.text = game.getHome() + "\n" + val;
        val        = Random.Range(game.getMargin() - 10, game.getMargin() + 10);
        side4.text = game.getHome() + "\n" + val;
        val        = Random.Range(game.getMargin() - 10, game.getMargin() + 10);
        side5.text = game.getHome() + "\n" + val;
        val        = Random.Range(game.getMargin() - 10, game.getMargin() + 10);
        side6.text = game.getHome() + "\n" + val;
        val        = Random.Range(game.getMargin() - 10, game.getMargin() + 10);
        side7.text = game.getHome() + "\n" + val;
        val        = Random.Range(game.getMargin() - 10, game.getMargin() + 10);
        side8.text = game.getHome() + "\n" + val;


//		int k = 1;
//		side1.text = "side " + k++;
//		side2.text = "side " + k++;
//		side3.text = "side " + k++;
//		side4.text = "side " + k++;
//		side5.text = "side " + k++;
//		side6.text = "side " + k++;
//		side7.text = "side " + k++;
//		side8.text = "side " + k++;

        sideV [0] = side1.text;
        sideV [1] = side2.text;
        sideV [2] = side3.text;
        sideV [3] = side4.text;
        sideV [4] = side5.text;
        sideV [5] = side6.text;
        sideV [6] = side7.text;
        sideV [7] = side8.text;
    }
Beispiel #33
0
        static void Main(string[] args)
        {
            Task   task      = GameClass.Timer(1, 10);
            bool   gameEnded = false;
            string input;

            while (GameClass.timeLeft > 0 && !gameEnded)
            {
                input = Console.ReadLine();
                if (input == "2" && GameClass.timeLeft > 0)
                {
                    Console.WriteLine("you win!");
                    GameClass.StopTask();
                    gameEnded = true;
                }
                else
                {
                    Console.WriteLine("try again!");
                }
            }
        }
    public PlayClass(GameClass parent)
    {
        this.parent     = parent;
        this.peerObject = peerObject;
        this.message    = new MessageDelegate(parent.MessageArrived);

        peerObject = new Peer();
        // First set up our event handlers (We only need events for the ones we care about)
        peerObject.PlayerCreated     += new PlayerCreatedEventHandler(this.PlayerCreated);
        peerObject.PlayerDestroyed   += new PlayerDestroyedEventHandler(this.PlayerDestroyed);
        peerObject.HostMigrated      += new HostMigratedEventHandler(this.HostMigrated);
        peerObject.Receive           += new ReceiveEventHandler(this.DataReceived);
        peerObject.SessionTerminated += new SessionTerminatedEventHandler(this.SessionTerminated);

        Connect = new ConnectWizard(peerObject, AppGuid, "Step2");
        if (!Connect.StartWizard())
        {
            MessageBox.Show("DirectPlay initialization was incomplete. Application will terminate.");
            throw new DirectXException();
        }
    }
Beispiel #35
0
 public Ship(Device device, GameClass gameClass, HullColors hullColor)
 {
     this.device = device;
     this.game   = gameClass;
     shots       = new Shots(device);
     if (hullColor == HullColors.White)
     {
         shipMesh         = new PositionedMesh(device, "WhiteShip.x");
         startingPosition = new Vector3(10, 0, 10);
     }
     else
     {
         shipMesh         = new PositionedMesh(device, "RedShip.x");
         startingPosition = new Vector3(-50, 0, -150);
     }
     vaporTrail = new ParticleEffects(device);
     vaporTrail.ParticleTexture = TextureLoader.FromFile(device,
                                                         MediaUtilities.FindFile("particle-blue.bmp"));
     shockWave = new Shockwave(device);
     SetRandomPosition(true);
 }
Beispiel #36
0
        private void UpdateCurrentMatch(GameClass game, int gameCount, int totalGames)
        {
            if (InvokeRequired)
            {
                Invoke(new UpdateCurrentMatchDelegate(UpdateCurrentMatch), (object)game, (object)gameCount, (object)totalGames);
            }
            else
            {
                leaderboard.UpdateCurrentMatch(string.Format("Game {4}/{5}:  {0} {2} vs {3} {1}", game.Bot1Name, game.Bot2Name, game.Bot1Points, game.Bot2Points, gameCount, totalGames));

                lblBot1Name.Text = game.Bot1Name;
                lblBot2Name.Text = game.Bot2Name;

                lblBot1Status.Text = string.Format("Game {0} in progress.", gameCount);
                lblBot2Status.Text = string.Format("Game {0} in progress.", gameCount);


                lblBot1Message.Text = game.Bot1Points.ToString();
                lblBot2Message.Text = game.Bot2Points.ToString();
            }
        }
        public bool Compile()
        {
            List <string> code_files = new List <string>(classes.Count + 1);

            code_files.Add(GameClass.GenerateCode());

            foreach (var c in classes)
            {
                code_files.Add(c.GenerateCode());
            }

            var prov       = new CSharpCodeProvider();
            var parameters = new CompilerParameters();

            parameters.GenerateExecutable = true;
            parameters.ReferencedAssemblies.AddRange(references.ToArray());
            parameters.MainClass = GameClass.Name;
            var results = prov.CompileAssemblyFromSource(parameters, code_files.ToArray());

            return(results.Errors.Count == 0);
        }
Beispiel #38
0
    private static TypeDefinition DumpClass(ClassDump dumper, ModuleDefinition target, GameClass runtimeClass)
    {
        // Check stack
        if (dumper.IsOnStack(runtimeClass))
        {
            return((TypeDefinition)dumper.GrabFromStack(runtimeClass));
        }

        // Create type definition
        TypeDefinition type = new TypeDefinition(runtimeClass.Namespace, runtimeClass.Name, runtimeClass.Flags);

        type.MetadataToken = new MetadataToken(runtimeClass.Token);

        // Add to stack
        dumper.PushToStack(runtimeClass, type);

        // Add type to assembly
        if (runtimeClass.Parent != IntPtr.Zero)
        {
            GameClass      parent     = new GameClass(runtimeClass.Parent);
            TypeDefinition parentType = DumpClass(dumper, target, parent);

            if (parentType == null)
            {
                target.Types.Add(type);
            }
            else
            {
                parentType.NestedTypes.Add(type);
            }
        }
        else
        {
            target.Types.Add(type);
        }

        // End
        return(type);
    }
        //==========================================================================
        //Player 0-99 (100 commands reserved or used for ) THESE ARE IN ORDER
        //==========================================================================
        void PlayerMove(int ammount, string direction, ref GameClass Game)
        {
            switch (direction)
            {
            case "N":
                Game.Character.Yloc -= ammount;
                break;

            case "E":
                Game.Character.Xloc += ammount;
                break;

            case "S":
                Game.Character.Yloc += ammount;
                break;

            case "W":
                Game.Character.Xloc -= ammount;
                break;
            }
            Game.Redraw();
        }
Beispiel #40
0
 private static TypeDefinition SearchType(IEnumerable <TypeDefinition> types, GameClass target)
 {
     if (types.Count() < 1)
     {
         return(null);
     }
     foreach (TypeDefinition type in types)
     {
         if (type.MetadataToken.ToUInt32() == target.Token)
         {
             return(type);
         }
         if (type.HasNestedTypes)
         {
             TypeDefinition returnedType = SearchType(type.NestedTypes, target);
             if (returnedType != null)
             {
                 return(returnedType);
             }
         }
     }
     return(null);
 }
    public PlayClass(GameClass Game)
    {
        this.game = Game;

        //Initialize our peer to peer network object
        peerObject = new Peer();

        // Set up our event handlers (We only need events for the ones we care about)
        peerObject.PlayerCreated += new PlayerCreatedEventHandler(PlayerCreated);
        peerObject.PlayerDestroyed += new PlayerDestroyedEventHandler(PlayerDestroyed);
        peerObject.Receive += new ReceiveEventHandler(game.DataReceived);
        peerObject.SessionTerminated += new SessionTerminatedEventHandler(SessionTerminated);

        // use the DirectPlay connection wizard to create our join sessions
        Connect = new ConnectWizard(peerObject, AppGuid, "Spacewar3D");
        Connect.StartWizard();

        inSession = Connect.InSession;

        if (inSession) {
            isHost = Connect.IsHost;
        }
    }
Beispiel #42
0
            public bool GetWinner()
            {
                while (!GameOver(p1, p2))
                {
                    if (CheckInfinite(p1, p2))
                    {
                        return(true);
                    }
                    int card1 = p1.cards.Dequeue();
                    int card2 = p2.cards.Dequeue();

                    if (card1 <= p1.cards.Count && card2 <= p2.cards.Count)
                    {
                        GameClass gc = new GameClass(p1, card1, p2, card2);
                        if (gc.GetWinner())
                        {
                            p1.GainCards(card1, card2);
                        }
                        else
                        {
                            p2.GainCards(card2, card1);
                        }
                        continue;
                    }

                    if (card1 > card2)
                    {
                        p1.GainCards(card1, card2);
                    }
                    else
                    {
                        p2.GainCards(card2, card1);
                    }
                }

                return(p2.cards.Count == 0);                //true => player 1 wins
            }
Beispiel #43
0
    public void OnEvent(CustomEventArgs messageData)
    {
        var message = messageData.Message;

        switch (message)
        {
        case GameEventName.GoUseAutoReward:
            var tokensReward = messageData.Value as List <TokenRewardEnum>;
            ProcessAutoUseTokens(tokensReward);
            break;

        case GameEventName.GoSelectTokenReward:
            _currentToken = messageData.Value as IToken;
            Debug.Log(_currentToken.GetDataToken().Token);
            FindEmptyCell();
            break;

        case GameEventName.GoAddTokenReward:
            _currentPlayer = (GameClass)messageData.Value;
            var token = _currentToken.GetDataToken().Token;
            var index = _dictionaryToken[_currentPlayer].IndexOf(TokenRewardEnum.Undefined);
            _dictionaryToken[_currentPlayer][index] = token;
            var art = _dictionaryIconToken[_currentPlayer][index].GetComponent <SpriteRenderer>();
            art.sprite = _currentToken.GetDataToken().Art;
            _publisher.Publish(null, new CustomEventArgs(GameEventName.GoEndSelectTokenReward, _currentToken));
            _currentToken = null;
            break;

        case GameEventName.GoRemoveTokenReward:
            break;

        case GameEventName.GoDeActivateTargetsPlayer:
            _currentToken = null;
            break;
        }
    }
Beispiel #44
0
    public void CreateIconTokenByGameClass(GameClass gameClass)
    {
        _dictionaryIconToken[gameClass] = new List <GameObject>();
        _dictionaryToken[gameClass]     = new List <TokenRewardEnum>()
        {
            TokenRewardEnum.Undefined, TokenRewardEnum.Undefined, TokenRewardEnum.Undefined
        };
        var cout = 0;

        foreach (var icon in _poolIconToken)
        {
            if (icon.activeSelf)
            {
                continue;
            }
            if (cout == 3)
            {
                return;
            }
            _dictionaryIconToken[gameClass].Add(icon);
            icon.SetActive(true);
            ++cout;
        }
    }
Beispiel #45
0
    //---------------------Создание инвентаря, заполнение слотов
    private void CreateInventory(GameClass player)
    {
        ClearInventory();
        var list = _inventoryPlayers[player];

        //---------------заполняем инвентарь (сумку)
        for (var i = 0; i < list.Count; i++)
        {
            if (list[i] == "")
            {
                continue;
            }
            SpawnItemInventory(i);
        }
        list = _equpmentCardsPlayers[player];
        for (var i = 0; i < list.Count; i++)
        {
            if (list[i] == "")
            {
                continue;
            }
            SpawnItemEqupmentCard(i);
        }
    }
Beispiel #46
0
 public Component(GameClass game, int x, int y, int width, int height)
 {
     this.game = game;
     Rect = new Rectangle(x, y, width, height);
 }
Beispiel #47
0
        public ActionResult Show(int id)
        {
            GameClass selectedGame = GameClass.Find(id);

            return(View("Show", selectedGame));
        }
Beispiel #48
0
 public Screen(GameClass game)
     : base(game)
 {
     Rect = new Rectangle(0, 0, Globals.ScreenWidth, Globals.ScreenHeight);
 }
Beispiel #49
0
 public Panel(GameClass game)
     : base(game)
 {
     init();
 }
Beispiel #50
0
 public void setGame(GameClass game)
 {
     Debug.Log ("setGameHERE " + game.getHome() + " " + game.getAway() );
     Game = new GameClass (game.getHome (), game.getAway (), game.getMargin ());
 }
Beispiel #51
0
    IEnumerator WaitForRequest(WWW www)
    {
        yield return www;

            // check for errors
        if (www.error == null)
        {
            Debug.Log("WWW Ok! - result: " + www.data);
            GameList = new List<GameClass>();
            string[] games = www.data.Split('\n');
            foreach(string game in games)
            {
                string[] game_data = game.Split(';');
                if(game_data.Length == 3)
                {
                    //Debug.Log("Game between:Home " + game_data[0] + " and " + game_data[1] + " margin is " + game_data[2]);
                    GameClass tempgame = new GameClass(game_data[0],game_data[1], int.Parse(game_data[2]));
                    GameList.Add(tempgame);
                }
            }
            MainPlane mainplane = (MainPlane) GameObject.Find ("PlaneMain").GetComponent<MainPlane>();
            mainplane.addGames(GameList);

        } else {
            Debug.Log("WWW Error: "+ www.error);
        }
    }
Beispiel #52
0
 public Panel(GameClass game, Rectangle rect)
     : base(game, rect)
 {
     init();
 }
Beispiel #53
0
    public void setText(GameClass game)
    {
        Debug.Log ("SETTEXT " + game.getHome() + " " + game.getAway() );
        int val = Random.Range (game.getMargin() - 10, game.getMargin() + 10);
        side1.text = game.getHome() + "\n" +  val;
        val = Random.Range (game.getMargin() - 10, game.getMargin() + 10);
        side2.text = game.getHome() + "\n" +  val;
        val = Random.Range (game.getMargin() - 10, game.getMargin() + 10);
        side3.text = game.getHome() + "\n" + val;
        val = Random.Range (game.getMargin() - 10, game.getMargin() + 10);
        side4.text = game.getHome() + "\n" + val;
        val = Random.Range (game.getMargin() - 10, game.getMargin() + 10);
        side5.text = game.getHome() + "\n" + val;
        val = Random.Range (game.getMargin() - 10, game.getMargin() + 10);
        side6.text = game.getHome() + "\n" + val;
        val = Random.Range (game.getMargin() - 10, game.getMargin() + 10);
        side7.text = game.getHome() + "\n" + val;
        val = Random.Range (game.getMargin() - 10, game.getMargin() + 10);
        side8.text = game.getHome() + "\n" +  val;

        //		int k = 1;
        //		side1.text = "side " + k++;
        //		side2.text = "side " + k++;
        //		side3.text = "side " + k++;
        //		side4.text = "side " + k++;
        //		side5.text = "side " + k++;
        //		side6.text = "side " + k++;
        //		side7.text = "side " + k++;
        //		side8.text = "side " + k++;

        sideV [0] = side1.text;
        sideV [1] = side2.text;
        sideV [2] = side3.text;
        sideV [3] = side4.text;
        sideV [4] = side5.text;
        sideV [5] = side6.text;
        sideV [6] = side7.text;
        sideV [7] = side8.text;
    }
Beispiel #54
0
 public OptionPanel(GameClass game)
     : base(game)
 {
     SelectedIndex = 0;
 }
Beispiel #55
0
 public Component(GameClass game, Rectangle rect)
     : this(game, rect.X, rect.Y, rect.Width, rect.Height)
 {
 }
Beispiel #56
0
 public Toggle(GameClass game, string text, int x, int y, int width, int height)
     : base(game, text, x, y, width, height)
 {
     init();
 }
Beispiel #57
0
 public Toggle(GameClass game, string text)
     : base(game, text)
 {
     init();
 }
Beispiel #58
0
 public Toggle(GameClass game)
     : base(game)
 {
     init();
 }
Beispiel #59
0
 public OptionPanel(GameClass game, Rectangle rect)
     : base(game, rect)
 {
     SelectedIndex = 0;
 }
Beispiel #60
0
 public Component(GameClass game)
 {
     this.game = game;
     Rect = new Rectangle();
 }