예제 #1
0
    public void OnActionWithKeyProtectBall(string key, Dictionary <string, ActionGame[]> ActionGames)
    {
        Debug.Log("Protect Move");
        int        r = Random.Range(0, ActionGames[key].Length);
        ActionGame a = ActionGames[key][r];

        switch (a.typeAction)
        {
        case ActionGame.TypeAction.Action:

            StartAcionWithTime(a.ActionStart, a.ActionUpdate, a.ActionRemove, a.time);

            break;

        case ActionGame.TypeAction.Update:

            StartActionUpdate(a.ActionStart, a.ActionUpdate);
            break;

        case ActionGame.TypeAction.ActionEFF:

            StartAcionEFFWithTime(a.ActionStart, a.ActionUpdate, a.ActionRemove, a.time);

            break;

        case ActionGame.TypeAction.ActionTrigger:

            StartActionTrigger(a.ActionStart, a.ActionUpdate);

            break;
        }
    }
예제 #2
0
    public void CallAction(ActionGame action, float quantidade)
    {
        switch (action)
        {
        case ActionGame.EscovarDente:
            if (higiene < 80)
            {
                float qnt = higiene + quantidade > 80 ? 80 - higiene : quantidade;
                AdicionarMedidor(Medidores.Higiene, qnt);
            }
            break;

        case ActionGame.LavarMao:
            efeitosPia.SetActive(true);
            this.ActionAfter(2, () =>
            {
                efeitosPia.SetActive(false);
                if (higiene < 80)
                {
                    float qnt = higiene + quantidade > 80 ? 80 - higiene : quantidade;
                    AdicionarMedidor(Medidores.Higiene, qnt);
                }
            });
            break;
        }
    }
예제 #3
0
    public override void Init()
    {
        ActionGame actionGame = new ActionGame(OnTriggerCatchAndThrow, OnStartCatchAndThrow, OnEndProtectToHoop, 0.6f);

        Directory_OnActionGame.Add(Key_Action_Catch_And_Throw, actionGame);
        base.Init();
    }
예제 #4
0
 /// <summary>
 /// Creates a new opponent human.
 /// </summary>
 /// <param name="game">The game</param>
 public Opponent(ActionGame game)
     : base(game, null, new PositionInTown(null, Vector2.Zero), 0, Matrix.Identity)
 {
     foreach (Tool gun in from gunType in game.PlayerDefaultGuns select new Gun(gunType, gunType.DefaultBulletCount, this, game))
     {
         AddTool(gun);
     }
 }
예제 #5
0
    public override void Init()
    {
        ActionGame lc_Move_Back = new ActionGame(OnTriggerMoveBackTo, OnStartMoveBackTo);

        Directory_OnActionGame.Add(Key_Action_Move_Back_To, lc_Move_Back);

        base.Init();
    }
예제 #6
0
 /// <summary>
 /// Creates a new opponent human.
 /// </summary>
 /// <param name="game">The game</param>
 public Opponent(ActionGame game)
     : base(game, null, new PositionInTown(null, Vector2.Zero), 0, Matrix.Identity)
 {
     foreach (Tool gun in from gunType in game.PlayerDefaultGuns select new Gun(gunType, gunType.DefaultBulletCount, this, game))
     {
         AddTool(gun);
     }
 }
예제 #7
0
    public void Init()
    {
        // Action Game
        ActionGame lc_SlampDunk = new ActionGame(OnTriggerSlampDunk, OnActionSlampDunk, UnActionSlampDunk, 2);
        ActionGame lc_Stun      = new ActionGame(OnTriggerStun, OnStartTriggerStun, OnEndTriggerStun, 0);

        // AddToDirectoryGame
        Directory_OnActionGame.Add(Key_Slamp_Dunk, lc_SlampDunk);
        Directory_OnActionGame.Add(Key_Stun, lc_Stun);
    }
예제 #8
0
파일: Player.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new player human.
 /// </summary>
 /// <param name="game">The game</param>
 public Player(ActionGame game)
     : base(game, null, new PositionInTown(null, Vector2.Zero), 0, Matrix.Identity)
 {
     defaultMousePosition = new Point(game.Settings.ScreenSize.Width / 2, game.Settings.ScreenSize.Height / 2);
     foreach (Tool gun in from gunType in game.PlayerDefaultGuns select new Gun(gunType, gunType.DefaultBulletCount, this, game))
     {
         AddTool(gun);
     }
     lastKeyPressedGameTime.Add(Game.Settings.RunWalkSwitch, TimeSpan.Zero);
     lastKeyPressedGameTime.Add(GodModeSwitch, TimeSpan.Zero);
     Running = true;
 }
예제 #9
0
파일: Player.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new player human.
 /// </summary>
 /// <param name="game">The game</param>
 public Player(ActionGame game)
     : base(game, null, new PositionInTown(null, Vector2.Zero), 0, Matrix.Identity)
 {
     defaultMousePosition = new Point(game.Settings.ScreenSize.Width / 2, game.Settings.ScreenSize.Height / 2);
     foreach (Tool gun in from gunType in game.PlayerDefaultGuns select new Gun(gunType, gunType.DefaultBulletCount, this, game))
     {
         AddTool(gun);
     }
     lastKeyPressedGameTime.Add(Game.Settings.RunWalkSwitch, TimeSpan.Zero);
     lastKeyPressedGameTime.Add(GodModeSwitch, TimeSpan.Zero);
     Running = true;
 }
예제 #10
0
 /// <summary>
 /// Creates a new instance of human
 /// </summary>
 /// <param name="game">The game</param>
 /// <param name="model">Model</param>
 /// <param name="position">Position</param>
 /// <param name="azimuth">Azimuth</param>
 /// <param name="worldTransform">World transform matrix</param>
 public Human(ActionGame game, Model model, PositionInTown position, double azimuth, Matrix worldTransform)
     : base(model, position, azimuth, worldTransform)
 {
     this.game = game;
     health    = 100;
     tools.AddRange(
         from gunType in game.HumanDefaultGuns select new Gun(gunType, gunType.DefaultBulletCount, this, game)
         );
     selectedToolIndex = 0;
     lastPosition      = position.PositionInQuarter;
     lastSeenEnemy     = null;
     lastTimeSawEnemy  = TimeSpan.Zero;
 }
예제 #11
0
    protected void FormatString_Aciton_Protect_Ball(string line)
    {
        string ss = "";

        // Debug.Log("Line Format : " + line);
        string[] w = new string[1] {
            "."
        };
        string[] w1 = new string[1] {
            "="
        };
        string[] w2 = new string[1] {
            "||"
        };
        string[] word = line.Split(w, System.StringSplitOptions.None);

        for (int i = 0; i < word.Length; i++)
        {
            //    Debug.Log(word[i]);
        }
        string[] word2 = word[1].Split(w1, System.StringSplitOptions.None);
        string   key   = word2[0].Trim();

        string[] value      = word2[1].Split(w2, System.StringSplitOptions.None);
        string[] ArrayValue = new string[value.Length];
        for (int i = 0; i < value.Length; i++)
        {
            ArrayValue[i] = value[i].Trim();
            ss           += " " + ArrayValue[i];
        }

        ActionGame[] ArrayAction = new ActionGame[value.Length];

        for (int i = 0; i < ArrayValue.Length; i++)
        {
            Debug.Log(ArrayValue[i]);
            ArrayAction[i] = Directory_OnActionGame[ArrayValue[i]];
        }


        Directory_Protect_Board.Add(key, ArrayAction);

        Debug.Log("Key : " + key + " " + ss);
    }
예제 #12
0
        /// <summary>
        /// Creates new town quarter as map fragment. Generates roads, buildings, etc.
        /// </summary>
        /// <param name="size">Size of quarter without joining interface</param>
        /// <param name="degree">Number of quarter's interfaces (joining streets)</param>
        public TownQuarter(ActionGame game, Vector2 size, int degree)
        {
            owner = EmptyTownQuarterOwner.Instance;

            this.game  = game;
            interfaces = new List <TownQuarterInterface>(degree);
            if (nameRepository.Count > 0)
            {
                Random rand      = new Random();
                int    nameIndex = rand.Next(0, nameRepository.Count - 1);
                Name = nameRepository[nameIndex];
                nameRepository.RemoveAt(nameIndex);
            }
            else
            {
                Name = emptyName;
            }

            int xSize = (int)Math.Floor(size.X / SquareWidth);
            int ySize = (int)Math.Floor(size.Y / SquareWidth);

            bitmapSize = new System.Drawing.Size(xSize, ySize);
            mapBitmap  = new MapFillType[bitmapSize.Width * bitmapSize.Height];
            for (int i = 0; i < mapBitmap.Length; i++)
            {
                mapBitmap[i] = MapFillType.Empty;
            }
            spaceGrid = new Grid(bitmapSize.Width, bitmapSize.Height, GridFiledWidth, GridFiledWidth);

            try
            {
                Generate(degree);
            }
            catch (Exception ex)
            {
                if (Name != emptyName)
                {
                    nameRepository.Add(Name);
                }
                throw ex;
            }
            spaceGrid.Fill(GetAllSolidObjects());
        }
예제 #13
0
        public void TypeChoosing(string type, Player player)
        {
            UI ui = new UI();

            int developer = 0;
            int name      = 1;
            int rating    = 2;

            if (type.Equals("Horror"))
            {
                string[]   datas = ui.GameDatasFromUser();
                HorrorGame game  = new HorrorGame(datas[developer], datas[name], Double.Parse(datas[rating]), type);
                game.EffectToPlayer(player, game);
            }

            else if (type.Equals("Survival"))
            {
                string[]     datas = ui.GameDatasFromUser();
                SurvivalGame game  = new SurvivalGame(datas[developer], datas[name], Double.Parse(datas[rating]), type);
                game.EffectToPlayer(player, game);
            }

            else if (type.Equals("Adventure"))
            {
                string[]      datas = ui.GameDatasFromUser();
                AdventureGame game  = new AdventureGame(datas[developer], datas[name], Double.Parse(datas[rating]), type);
                game.EffectToPlayer(player, game);
            }

            else if (type.Equals("Action"))
            {
                string[]   datas = ui.GameDatasFromUser();
                ActionGame game  = new ActionGame(datas[developer], datas[name], Double.Parse(datas[rating]), type);
                game.EffectToPlayer(player, game);
            }

            else
            {
                ui.ErrorMessage("Wrong type of attribute!");
                System.Environment.Exit(0);
            }
        }
예제 #14
0
    public void OnActionWithKey(string key)
    {
        Debug.Log(key);

        ActionGame a = Directory_OnActionGame[key];

        switch (a.typeAction)
        {
        case ActionGame.TypeAction.Action:

            StartAcionWithTime(a.ActionStart, a.ActionUpdate, a.ActionRemove, a.time);

            break;

        case ActionGame.TypeAction.Update:

            StartActionUpdate(a.ActionStart, a.ActionUpdate);
            break;
        }
    }
예제 #15
0
        public MainMenu(ActionGame game, bool videoEnabled)
        {
            InitializeComponent();
            DialogResult = DialogResult.Cancel;
            this.game    = game;
            if (!videoEnabled)
            {
                //tabControl1.TabPages.RemoveAt(1);
                fullScreenChb.Enabled = false;
                resolutionCmb.Enabled = false;
                fullScreenChb.Checked = game.Settings.Fullscreen;
                resolutionCmb.Text    = String.Format("{0}x{1}", game.Settings.ScreenSize.Width, game.Settings.ScreenSize.Height);
            }

            ForwardSelector        = new KeySelector("Move forward", Microsoft.Xna.Framework.Input.Keys.W);
            BackwardSelector       = new KeySelector("Move backward", Microsoft.Xna.Framework.Input.Keys.S);
            StepLeftSelector       = new KeySelector("Left step", Microsoft.Xna.Framework.Input.Keys.A);
            StepRightSelector      = new KeySelector("Right step", Microsoft.Xna.Framework.Input.Keys.D);
            TurnLeftSelector       = new KeySelector("Turn left", Microsoft.Xna.Framework.Input.Keys.Left);
            TurnRightSelector      = new KeySelector("Turn right", Microsoft.Xna.Framework.Input.Keys.Right);
            TurnUpSelector         = new KeySelector("Turn up", Microsoft.Xna.Framework.Input.Keys.Up);
            TurnDownSelector       = new KeySelector("Turn down", Microsoft.Xna.Framework.Input.Keys.Down);
            RunWalkSwitchSelector  = new KeySelector("Run / Walk", Microsoft.Xna.Framework.Input.Keys.CapsLock);
            ShowQuarterMapSelector = new KeySelector("Show quarter map", Microsoft.Xna.Framework.Input.Keys.M);
            ShowTownMapSelector    = new KeySelector("Show town map", Microsoft.Xna.Framework.Input.Keys.N);
            CameraSwitchSelector   = new KeySelector("Change camera mode", Microsoft.Xna.Framework.Input.Keys.C);
            keyselectorsFlowPanel.Controls.Add(ForwardSelector);
            keyselectorsFlowPanel.Controls.Add(BackwardSelector);
            keyselectorsFlowPanel.Controls.Add(StepLeftSelector);
            keyselectorsFlowPanel.Controls.Add(StepRightSelector);
            keyselectorsFlowPanel.Controls.Add(TurnLeftSelector);
            keyselectorsFlowPanel.Controls.Add(TurnRightSelector);
            keyselectorsFlowPanel.Controls.Add(TurnUpSelector);
            keyselectorsFlowPanel.Controls.Add(TurnDownSelector);
            keyselectorsFlowPanel.Controls.Add(RunWalkSwitchSelector);
            keyselectorsFlowPanel.Controls.Add(ShowQuarterMapSelector);
            keyselectorsFlowPanel.Controls.Add(ShowTownMapSelector);
            keyselectorsFlowPanel.Controls.Add(CameraSwitchSelector);
        }
예제 #16
0
        public MainMenu(ActionGame game, bool videoEnabled)
        {
            InitializeComponent();
            DialogResult = DialogResult.Cancel;
            this.game = game;
            if (!videoEnabled)
            {
                //tabControl1.TabPages.RemoveAt(1);
                fullScreenChb.Enabled = false;
                resolutionCmb.Enabled = false;
                fullScreenChb.Checked = game.Settings.Fullscreen;
                resolutionCmb.Text = String.Format("{0}x{1}", game.Settings.ScreenSize.Width, game.Settings.ScreenSize.Height);
            }

            ForwardSelector = new KeySelector("Move forward", Microsoft.Xna.Framework.Input.Keys.W);
            BackwardSelector = new KeySelector("Move backward", Microsoft.Xna.Framework.Input.Keys.S);
            StepLeftSelector = new KeySelector("Left step", Microsoft.Xna.Framework.Input.Keys.A);
            StepRightSelector = new KeySelector("Right step", Microsoft.Xna.Framework.Input.Keys.D);
            TurnLeftSelector = new KeySelector("Turn left", Microsoft.Xna.Framework.Input.Keys.Left);
            TurnRightSelector = new KeySelector("Turn right", Microsoft.Xna.Framework.Input.Keys.Right);
            TurnUpSelector = new KeySelector("Turn up", Microsoft.Xna.Framework.Input.Keys.Up);
            TurnDownSelector = new KeySelector("Turn down", Microsoft.Xna.Framework.Input.Keys.Down);
            RunWalkSwitchSelector = new KeySelector("Run / Walk", Microsoft.Xna.Framework.Input.Keys.CapsLock);
            ShowQuarterMapSelector = new KeySelector("Show quarter map", Microsoft.Xna.Framework.Input.Keys.M);
            ShowTownMapSelector = new KeySelector("Show town map", Microsoft.Xna.Framework.Input.Keys.N);
            CameraSwitchSelector = new KeySelector("Change camera mode", Microsoft.Xna.Framework.Input.Keys.C);
            keyselectorsFlowPanel.Controls.Add(ForwardSelector);
            keyselectorsFlowPanel.Controls.Add(BackwardSelector);
            keyselectorsFlowPanel.Controls.Add(StepLeftSelector);
            keyselectorsFlowPanel.Controls.Add(StepRightSelector);
            keyselectorsFlowPanel.Controls.Add(TurnLeftSelector);
            keyselectorsFlowPanel.Controls.Add(TurnRightSelector);
            keyselectorsFlowPanel.Controls.Add(TurnUpSelector);
            keyselectorsFlowPanel.Controls.Add(TurnDownSelector);
            keyselectorsFlowPanel.Controls.Add(RunWalkSwitchSelector);
            keyselectorsFlowPanel.Controls.Add(ShowQuarterMapSelector);
            keyselectorsFlowPanel.Controls.Add(ShowTownMapSelector);
            keyselectorsFlowPanel.Controls.Add(CameraSwitchSelector);
        }
예제 #17
0
파일: HealBox.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new heal box.
 /// </summary>
 /// <param name="healPercentage">Percentage that will be added to the human's health status if he takes it.</param>
 /// <param name="game">The game</param>
 /// <param name="takeSound">The take sound effect</param>
 /// <param name="model">Model of the box</param>
 /// <param name="position">Position</param>
 /// <param name="world">World transformation matrix</param>
 public HealBox(int healPercentage, ActionGame game, SoundEffect takeSound, Model model, PositionInTown position, Matrix world)
     : base(game, takeSound, model, position, world)
 {
     this.healPercentage = healPercentage;
 }
예제 #18
0
파일: Camera.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new camera component.
 /// </summary>
 /// <param name="game">The game it is situated in</param>
 public Camera(ActionGame game)
     : base(game)
 {
 }
예제 #19
0
        /// <summary>
        /// Creates new town quarter as map fragment. Generates roads, buildings, etc.
        /// </summary>
        /// <param name="size">Size of quarter without joining interface</param>
        /// <param name="degree">Number of quarter's interfaces (joining streets)</param>
        public TownQuarter(ActionGame game, Vector2 size, int degree)
        {
            owner = EmptyTownQuarterOwner.Instance;

            this.game = game;
            interfaces = new List<TownQuarterInterface>(degree);
            if (nameRepository.Count > 0)
            {
                Random rand = new Random();
                int nameIndex = rand.Next(0, nameRepository.Count - 1);
                Name = nameRepository[nameIndex];
                nameRepository.RemoveAt(nameIndex);
            }
            else
            {
                Name = emptyName;
            }

            int xSize = (int)Math.Floor(size.X / SquareWidth);
            int ySize = (int)Math.Floor(size.Y / SquareWidth);
            bitmapSize = new System.Drawing.Size(xSize, ySize);
            mapBitmap = new MapFillType[bitmapSize.Width * bitmapSize.Height];
            for (int i = 0; i < mapBitmap.Length; i++)
                mapBitmap[i] = MapFillType.Empty;
            spaceGrid = new Grid(bitmapSize.Width, bitmapSize.Height, GridFiledWidth, GridFiledWidth);

            try
            {
                Generate(degree);
            }
            catch (Exception ex)
            {
                if (Name != emptyName)
                {
                    nameRepository.Add(Name);
                }
                throw ex;
            }
            spaceGrid.Fill(GetAllSolidObjects());
        }
예제 #20
0
    public override void Init()
    {
        ActionGame lc_OnActionMoveToPlayer = new ActionGame(OnTriggerMoveToPlayer, OnMoveToPlayer);
        ActionGame lc_OnActionMove         = new ActionGame(null, OnMoveToBall);
        ActionGame lc_OnJump       = new ActionGame(OnJump, OnJumpStraight, Endjump, 0.75f);
        ActionGame lc_OnIdle       = new ActionGame(null, OnMoveIde, EndAction, 0.5f);
        ActionGame lc_OnMoveRandom = new ActionGame(null, OnMoveRandom);
        ActionGame lc_onMoveToHoop = new ActionGame(null, OnMoveToHoop);
        ActionGame lc_OnJump_left  = new ActionGame(OnTriggerJumpLeft, OnJumpLeft, Endjump, 1f);
        ActionGame lc_OnJump_right = new ActionGame(OnJump, OnJumpRight, Endjump, 1f);
        ActionGame lc_OnSlampDunk  = new ActionGame(OnTriggerSlampDunk, OnActionSlampDunk, OnEndSlampDunk, 2, true);
        ActionGame lc_OnStun       = new ActionGame(OnTriggerStun, OnStun, OnEndTriggerStun, 0);

        ActionGame lc_OnAttack    = new ActionGame(OnStartActionAttack, OnActtionTriggerAttack, null);
        ActionGame lc_OnCatchBall = new ActionGame(OnStartActionCatchBall, OnActtionTriggerCatchBall, null);

        ActionGame lc_OnThrowOnGround = new ActionGame(OnStartThrowOnEarth, OnUpdateThrowOnEarth, OnEndThrowOnEarth, 0.5f);

        ActionGame lc_OnActionMoveToBall = new ActionGame(null, OnMoveToBall, EndAction, 1);

        ActionGame lc_OnMoveBackHaveBall = new ActionGame(OnStartMoveBackHaveBall, OnMoveBackHaveBall, EndActionMoveBackHaveBall, 2.5f);

        ActionGame lc_OnActionJumpThrowBall = new ActionGame(OnJumpThrowBall, OnStartThrowBall, EndAction, 1);

        ActionGame lc_OnActionMoveProtectBall = new ActionGame(OnTriggerMoveProtectHoop, OnMoveProtectHoop);

        // Update To Directory



        //  Update
        Directory_OnActionGame.Add(Key_Move_To_Ball, lc_OnActionMove);
        Directory_OnActionGame.Add(Key_Move_Ide, lc_OnIdle);
        Directory_OnActionGame.Add(Key_Move_Random, lc_OnMoveRandom);
        Directory_OnActionGame.Add(Key_Move_To_Hoop, lc_onMoveToHoop);
        Directory_OnActionGame.Add(Key_Stun, lc_OnStun);
        Directory_OnActionGame.Add(Key_Move_To_Player, lc_OnActionMoveToPlayer);



        //  Action

        Directory_OnActionGame.Add(Key_Action_Move_To_Ball, lc_OnActionMoveToBall);
        Directory_OnActionGame.Add(Key_Jump_Straight, lc_OnJump);
        Directory_OnActionGame.Add(Key_Jump_Left, lc_OnJump_left);
        Directory_OnActionGame.Add(Key_Jump_Right, lc_OnJump_right);
        Directory_OnActionGame.Add(Key_Thown_On_Ground, lc_OnThrowOnGround);
        Directory_OnActionGame.Add(Key_Action_Move_Back_Have_Ball, lc_OnMoveBackHaveBall);
        Directory_OnActionGame.Add(Key_Action_Jump_Throw_Ball, lc_OnActionJumpThrowBall);
        Directory_OnActionGame.Add(Key_Action_Protect_Ball, lc_OnActionMoveProtectBall);

        // Action EFF

        Directory_OnActionGame.Add(Key_Slamp_Dunk, lc_OnSlampDunk);

        // ACtion Trigger
        Directory_OnActionGame.Add(Key_Action_Trigger_Attack, lc_OnAttack);
        Directory_OnActionGame.Add(Key_Action_Trigger_CatchBall, lc_OnCatchBall);



        // Status

        Directory_StatusCpu.Add(Key_Trigger_Have_Ball, 0);
        Directory_StatusCpu.Add(Key_Trigger_Front, 0);
        Directory_StatusCpu.Add(Key_Trigger_Back, 0);
        Directory_StatusCpu.Add(Key_Trigger_Jump, 0);
        Directory_StatusCpu.Add(Key_Trigger_ThrowBall, 0);
        Directory_StatusCpu.Add(Key_Trigger_Slamp_Dunk, 0);
        Directory_StatusCpu.Add(Key_Trigger_Jump_Protect_Ball, 0);

        // Load Text Cpu

        ProcessKey ProcessProtectBoard = new ProcessKey(OnTriggerStatusMoveProtectBall, ProcessKey_Protect_Board);

        ProcessKey KeyMoveToBall              = new ProcessKey(OnTriggerStatusMoveCatchBall, ProcessStatus);
        ProcessKey KeyProcessStatusHaveBall   = new ProcessKey(OnTriggerCpuHaveBall, ProcessStatusCPUHaveBall);
        ProcessKey KeyProcessStatusPlayerHave = new ProcessKey(OnTriggerPlayerHaveBall, ProcessStatusPlayerHaveBall);

        ListProcessKey.Add(ProcessProtectBoard);
        ListProcessKey.Add(KeyMoveToBall);
        ListProcessKey.Add(KeyProcessStatusHaveBall);
        ListProcessKey.Add(KeyProcessStatusPlayerHave);

        ReadFileCPU();
    }
예제 #21
0
 /// <summary>
 /// Creates a new tool.
 /// </summary>
 /// <param name="icon">Used icon for toolbar</param>
 /// <param name="handler">The human that is holding this toolBarText</param>
 /// <param name="game">The game</param>
 public Tool(Texture2D icon, Human handler, ActionGame game)
     : this(icon)
 {
     this.holder = handler;
     this.game   = game;
 }
예제 #22
0
 /// <summary>
 /// Creates a new operation.
 /// </summary>
 /// <param name="game">The game</param>
 public Operation(ActionGame game)
 {
     this.game = game;
 }
예제 #23
0
파일: Gun.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new gun.
 /// </summary>
 /// <param name="type">The type of this gun</param>
 /// <param name="bullets">The number of available ammo</param>
 /// <param name="game">The game</param>
 public Gun(GunType type, int bullets, ActionGame game)
     : this(type, bullets, null, game)
 {
 }
예제 #24
0
 /// <summary>
 /// Creates a new operation.
 /// </summary>
 /// <param name="game">The game</param>
 public Operation(ActionGame game)
 {
     this.game = game;
 }
예제 #25
0
 public ContentRepository(ActionGame game)
 {
     this.game = game;
 }
예제 #26
0
 public ContentRepository(ActionGame game)
 {
     this.game = game;
 }
예제 #27
0
 public KillPlayerOperation(ActionGame game)
     : base(game)
 {
 }
예제 #28
0
 /// <summary>
 /// Creates a new sound playing component.
 /// </summary>
 /// <param name="game"></param>
 public SoundPlayer(ActionGame game)
 {
     this.game = game;
 }
예제 #29
0
파일: Gun.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new gun
 /// </summary>
 /// <param name="type">The type of this gun</param>
 /// <param name="bullets">The number of available ammo</param>
 /// <param name="handler">The holder of this gun</param>
 /// <param name="game">The game</param>
 public Gun(GunType type, int bullets, Human handler, ActionGame game)
     : base(type.Icon, handler, game)
 {
     this.type = type;
     this.bullets = bullets;
 }
예제 #30
0
 /// <summary>
 /// Creates a new sound playing component.
 /// </summary>
 /// <param name="game"></param>
 public SoundPlayer(ActionGame game)
 {
     this.game = game;
 }
예제 #31
0
파일: Town.cs 프로젝트: havri/ActionGame
        /// <summary>
        /// Creates and generates the whole town.
        /// </summary>
        /// <param name="game">The game</param>
        /// <param name="loadingFrom">Loading form where the generating progress will be shown</param>
        public Town(ActionGame game, Loading loadingFrom)
            : base(game)
        {
            EmptyTownQuarterOwner.LoadContent(game.Content);

            quarters = new TownQuarter[game.Settings.TownQuarterCount];

            //Town graph creation
            loadingFrom.SetLabel("Generating town graph...");
            loadingFrom.SetValue(0);
            int[] degrees = new int[game.Settings.TownQuarterCount];
            bool[,] edges = new bool[game.Settings.TownQuarterCount, game.Settings.TownQuarterCount]; // Graph is unoriented (symetric). edges[i, j] can be true only if i<j!
            for (int i = 0; i < game.Settings.TownQuarterCount - 1; i++)                              // First is made path through all. Graph has to have only one component.
            {
                int j = i + 1;
                degrees[i]++;
                degrees[j]++;
                edges[i, j] = true;
            }
            for (int i = 0; i < game.Settings.TownQuarterCount; i++)
            {
                loadingFrom.SetValue(100 * i / game.Settings.TownQuarterCount);
                for (int j = i + 1; j < game.Settings.TownQuarterCount; j++) //graph isn't oriented and reflexion is denied
                {
                    if (!edges[i, j] && degrees[i] < MaxQuarterDegree && degrees[j] < MaxQuarterDegree)
                    {
                        if (game.Random.NextDouble() < 0.65)
                        {
                            degrees[i]++;
                            degrees[j]++;
                            edges[i, j] = true;
                        }
                    }
                }
            }

            //Quarter creating by degrees
            loadingFrom.SetLabel("Generating quarters and streets...");
            loadingFrom.SetValue(0);
            for (int i = 0; i < game.Settings.TownQuarterCount; i++)
            {
                loadingFrom.SetValue(100 * i / game.Settings.TownQuarterCount);
                float perimeterLength = MinSideLengthPerInterface * Math.Max(degrees[i], 4);            // Even interface isn't needed the side must be there
                perimeterLength *= (float)game.Random.NextDouble() + 1f;                                //Minimal length can be doubled
                float width  = (perimeterLength / 2f) * (float)(game.Random.NextDouble() * 0.3 + 0.35); //aspect ratio
                float height = (perimeterLength / 2f) - width;
                if (width < MinQuarterSideLength)
                {
                    width = MinQuarterSideLength;
                }
                if (height < MinQuarterSideLength)
                {
                    height = MinQuarterSideLength;
                }

                do
                {
                    try
                    {
                        TownQuarter quarter = new TownQuarter(game, new Vector2(width, height), degrees[i]);
                        quarters[i] = quarter;
                    }
                    catch (NoSpaceForInterfaceException)
                    {
                        float widthIncement = MinSideLengthPerInterface * (float)game.Random.NextDouble();
                        width  += widthIncement;
                        height += MinSideLengthPerInterface - widthIncement;
                    }
                }while (quarters[i] == null);
            }


            //Joining interfaces
            loadingFrom.SetLabel("Building town...");
            loadingFrom.SetValue(0);
            for (int i = 0; i < game.Settings.TownQuarterCount; i++)
            {
                loadingFrom.SetValue(100 * i / game.Settings.TownQuarterCount);
                for (int j = i + 1; j < game.Settings.TownQuarterCount; j++)
                {
                    if (edges[i, j])
                    {
                        TownQuarterInterface ifaceI = (from iface in quarters[i].Interfaces where iface.OppositeInterface == null orderby game.Random.Next() select iface).First();
                        TownQuarterInterface ifaceJ = (from iface in quarters[j].Interfaces where iface.OppositeInterface == null orderby game.Random.Next() select iface).First();
                        ifaceI.OppositeInterface = ifaceJ;
                        ifaceJ.OppositeInterface = ifaceI;
                        ifaceI.LeftPathGraphVertex.AddNeighborBothDirection(ifaceJ.RightPathGraphVertex, TownQuarter.SquareWidth);
                        ifaceI.RightPathGraphVertex.AddNeighborBothDirection(ifaceJ.LeftPathGraphVertex, TownQuarter.SquareWidth);
                    }
                }
            }
            foreach (var quarter in quarters)
            {
                quarter.BuildInterfaceRoadSigns();
            }

            //Town map base creating
            {
                Bitmap mapRaster = new Bitmap(MapImageWidth, MapImageHeight);
                using (Graphics graphics = Graphics.FromImage(mapRaster))
                {
                    graphics.FillRectangle(Brushes.White, 0, 0, mapRaster.Width, mapRaster.Height);
                    float  angleJump = MathHelper.TwoPi / Game.Settings.TownQuarterCount;
                    float  radius    = Math.Min(MapImageWidth, MapImageHeight) / 2f - 20f;
                    PointF center    = new PointF(MapImageWidth / 2f, MapImageHeight / 2f);

                    for (int i = 0; i < Game.Settings.TownQuarterCount; i++)
                    {
                        for (int j = i + 1; j < Game.Settings.TownQuarterCount; j++)
                        {
                            if (edges[i, j])
                            {
                                graphics.DrawLine(Pens.Green,
                                                  center.X + (float)Math.Cos(i * angleJump) * radius,
                                                  center.Y + (float)Math.Sin(i * angleJump) * radius,
                                                  center.X + (float)Math.Cos(j * angleJump) * radius,
                                                  center.Y + (float)Math.Sin(j * angleJump) * radius
                                                  );
                            }
                        }
                    }

                    for (int i = 0; i < Game.Settings.TownQuarterCount; i++)
                    {
                        graphics.FillEllipse(Brushes.Black,
                                             center.X + (float)Math.Cos(i * angleJump) * radius - 3.5f,
                                             center.Y + (float)Math.Sin(i * angleJump) * radius - 3.5f,
                                             7, 7);
                        graphics.DrawString(quarters[i].Name, new Font("Verdana", 12), Brushes.Black, center.X + (float)Math.Cos(i * angleJump) * radius, center.Y + (float)Math.Sin(i * angleJump) * radius - 16);
                    }
                }
                mapImage = mapRaster;
            }

            GC.Collect();

            //Selecting starting quarter
            currentQuarter = quarters[0];
        }
예제 #32
0
파일: Gun.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new gun.
 /// </summary>
 /// <param name="type">The type of this gun</param>
 /// <param name="bullets">The number of available ammo</param>
 /// <param name="game">The game</param>
 public Gun(GunType type, int bullets, ActionGame game)
     : this(type, bullets, null, game)
 {
 }
예제 #33
0
파일: Gun.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new gun
 /// </summary>
 /// <param name="type">The type of this gun</param>
 /// <param name="bullets">The number of available ammo</param>
 /// <param name="handler">The holder of this gun</param>
 /// <param name="game">The game</param>
 public Gun(GunType type, int bullets, Human handler, ActionGame game)
     : base(type.Icon, handler, game)
 {
     this.type    = type;
     this.bullets = bullets;
 }
예제 #34
0
 /// <summary>
 /// Creates new action object.
 /// </summary>
 /// <param name="game">The game</param>
 /// <param name="actionDistance">Distance from which the action can be performed</param>
 /// <param name="model">Model of the action object</param>
 /// <param name="position">Position</param>
 /// <param name="azimuth">Azimuth</param>
 /// <param name="worldTransform">World transform matrix</param>
 public ActionObject(ActionGame game, float actionDistance, Model model, PositionInTown position, double azimuth, Matrix worldTransform)
     : base(model, position, azimuth, worldTransform)
 {
     this.actionDistance = actionDistance;
     this.game = game;
 }
예제 #35
0
 public CaptureFlagOperation(ActionGame game, int quarterIndex)
     : base(game, game.Town.Quarters[quarterIndex].Flag)
 {
     this.quarterIndex = quarterIndex;
 }
예제 #36
0
 /// <summary>
 /// Creates new action object.
 /// </summary>
 /// <param name="game">The game</param>
 /// <param name="actionDistance">Distance from which the action can be performed</param>
 /// <param name="model">Model of the action object</param>
 /// <param name="position">Position</param>
 /// <param name="azimuth">Azimuth</param>
 /// <param name="worldTransform">World transform matrix</param>
 public ActionObject(ActionGame game, float actionDistance, Model model, PositionInTown position, double azimuth, Matrix worldTransform)
     : base(model, position, azimuth, worldTransform)
 {
     this.actionDistance = actionDistance;
     this.game           = game;
 }
예제 #37
0
파일: HealBox.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new heal box.
 /// </summary>
 /// <param name="healPercentage">Percentage that will be added to the human's health status if he takes it.</param>
 /// <param name="game">The game</param>
 /// <param name="takeSound">The take sound effect</param>
 /// <param name="model">Model of the box</param>
 /// <param name="position">Position</param>
 /// <param name="world">World transformation matrix</param>
 public HealBox(int healPercentage, ActionGame game, SoundEffect takeSound, Model model, PositionInTown position, Matrix world)
     : base(game, takeSound, model, position, world)
 {
     this.healPercentage = healPercentage;
 }
예제 #38
0
 public KillPlayerOperation(ActionGame game)
     : base(game)
 {
 }
예제 #39
0
 /// <summary>
 /// Creates a new Box
 /// </summary>
 /// <param name="game">The game</param>
 /// <param name="takeSound">Sound that will be played if the box is taken</param>
 /// <param name="model"></param>
 /// <param name="position"></param>
 /// <param name="world"></param>
 public Box(ActionGame game, SoundEffect takeSound, Model model, PositionInTown position, Matrix world)
     : base(model, position, 0, world)
 {
     this.takeSound = takeSound;
     this.game      = game;
 }
예제 #40
0
파일: Town.cs 프로젝트: havri/ActionGame
        /// <summary>
        /// Creates and generates the whole town.
        /// </summary>
        /// <param name="game">The game</param>
        /// <param name="loadingFrom">Loading form where the generating progress will be shown</param>
        public Town(ActionGame game, Loading loadingFrom)
            : base(game)
        {
            EmptyTownQuarterOwner.LoadContent(game.Content);

            quarters = new TownQuarter[game.Settings.TownQuarterCount];

            //Town graph creation
            loadingFrom.SetLabel("Generating town graph...");
            loadingFrom.SetValue(0);
            int[] degrees = new int[game.Settings.TownQuarterCount];
            bool[,] edges = new bool[game.Settings.TownQuarterCount, game.Settings.TownQuarterCount]; // Graph is unoriented (symetric). edges[i, j] can be true only if i<j!
            for (int i = 0; i < game.Settings.TownQuarterCount - 1; i++) // First is made path through all. Graph has to have only one component.
            {
                int j = i + 1;
                degrees[i]++;
                degrees[j]++;
                edges[i, j] = true;
            }
            for (int i = 0; i < game.Settings.TownQuarterCount; i++)
            {
                loadingFrom.SetValue(100 * i / game.Settings.TownQuarterCount);
                for (int j = i + 1; j < game.Settings.TownQuarterCount; j++) //graph isn't oriented and reflexion is denied
                {
                    if (!edges[i, j] && degrees[i] < MaxQuarterDegree && degrees[j] < MaxQuarterDegree)
                    {
                        if (game.Random.NextDouble() < 0.65)
                        {
                            degrees[i]++;
                            degrees[j]++;
                            edges[i, j] = true;
                        }
                    }
                }
            }

            //Quarter creating by degrees
            loadingFrom.SetLabel("Generating quarters and streets...");
            loadingFrom.SetValue(0);
            for (int i = 0; i < game.Settings.TownQuarterCount; i++)
            {
                loadingFrom.SetValue(100 * i / game.Settings.TownQuarterCount);
                float perimeterLength = MinSideLengthPerInterface * Math.Max(degrees[i], 4); // Even interface isn't needed the side must be there
                perimeterLength *= (float)game.Random.NextDouble() + 1f; //Minimal length can be doubled
                float width = (perimeterLength / 2f) * (float)(game.Random.NextDouble() * 0.3 + 0.35); //aspect ratio
                float height = (perimeterLength / 2f) - width;
                if (width < MinQuarterSideLength)
                    width = MinQuarterSideLength;
                if (height < MinQuarterSideLength)
                    height = MinQuarterSideLength;

                do
                {
                    try
                    {
                        TownQuarter quarter = new TownQuarter(game, new Vector2(width, height), degrees[i]);
                        quarters[i] = quarter;
                    }
                    catch (NoSpaceForInterfaceException)
                    {
                        float widthIncement = MinSideLengthPerInterface * (float)game.Random.NextDouble();
                        width += widthIncement;
                        height += MinSideLengthPerInterface - widthIncement;
                    }
                }
                while (quarters[i] == null);
            }

            //Joining interfaces
            loadingFrom.SetLabel("Building town...");
            loadingFrom.SetValue(0);
            for (int i = 0; i < game.Settings.TownQuarterCount; i++)
            {
                loadingFrom.SetValue(100 * i / game.Settings.TownQuarterCount);
                for (int j = i + 1; j < game.Settings.TownQuarterCount; j++)
                {
                    if (edges[i, j])
                    {
                        TownQuarterInterface ifaceI = (from iface in quarters[i].Interfaces where iface.OppositeInterface == null orderby game.Random.Next() select iface).First();
                        TownQuarterInterface ifaceJ = (from iface in quarters[j].Interfaces where iface.OppositeInterface == null orderby game.Random.Next() select iface).First();
                        ifaceI.OppositeInterface = ifaceJ;
                        ifaceJ.OppositeInterface = ifaceI;
                        ifaceI.LeftPathGraphVertex.AddNeighborBothDirection(ifaceJ.RightPathGraphVertex, TownQuarter.SquareWidth);
                        ifaceI.RightPathGraphVertex.AddNeighborBothDirection(ifaceJ.LeftPathGraphVertex, TownQuarter.SquareWidth);
                    }
                }
            }
            foreach (var quarter in quarters)
            {
                quarter.BuildInterfaceRoadSigns();
            }

            //Town map base creating
            {
                Bitmap mapRaster = new Bitmap(MapImageWidth, MapImageHeight);
                using (Graphics graphics = Graphics.FromImage(mapRaster))
                {
                    graphics.FillRectangle(Brushes.White, 0, 0, mapRaster.Width, mapRaster.Height);
                    float angleJump = MathHelper.TwoPi / Game.Settings.TownQuarterCount;
                    float radius = Math.Min(MapImageWidth, MapImageHeight) / 2f - 20f;
                    PointF center = new PointF(MapImageWidth / 2f, MapImageHeight / 2f);

                    for (int i = 0; i < Game.Settings.TownQuarterCount; i++)
                    {
                        for (int j = i + 1; j < Game.Settings.TownQuarterCount; j++)
                        {
                            if (edges[i, j])
                            {
                                graphics.DrawLine(Pens.Green,
                                    center.X + (float)Math.Cos(i * angleJump) * radius,
                                    center.Y + (float)Math.Sin(i * angleJump) * radius,
                                    center.X + (float)Math.Cos(j * angleJump) * radius,
                                    center.Y + (float)Math.Sin(j * angleJump) * radius
                                    );
                            }
                        }
                    }

                    for (int i = 0; i < Game.Settings.TownQuarterCount; i++)
                    {
                        graphics.FillEllipse(Brushes.Black,
                            center.X + (float)Math.Cos(i * angleJump) * radius - 3.5f,
                            center.Y + (float)Math.Sin(i * angleJump) * radius - 3.5f,
                            7, 7);
                        graphics.DrawString(quarters[i].Name, new Font("Verdana", 12), Brushes.Black, center.X + (float)Math.Cos(i * angleJump) * radius, center.Y + (float)Math.Sin(i * angleJump) * radius - 16);
                    }
                }
                mapImage = mapRaster;
            }

            GC.Collect();

            //Selecting starting quarter
            currentQuarter = quarters[0];
        }
예제 #41
0
 public TakeBoxOperation(ActionGame game, Box box)
     : base(game)
 {
     this.box = box;
 }
예제 #42
0
파일: Tool.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new tool.
 /// </summary>
 /// <param name="icon">Used icon for toolbar</param>
 /// <param name="handler">The human that is holding this toolBarText</param>
 /// <param name="game">The game</param>
 public Tool(Texture2D icon, Human handler, ActionGame game)
     : this(icon)
 {
     this.holder = handler;
     this.game = game;
 }
예제 #43
0
 /// <summary>
 /// Creates a new flag action object
 /// </summary>
 /// <param name="game">The game</param>
 /// <param name="model">Model</param>
 /// <param name="position">Position</param>
 /// <param name="azimuth">Azimuth</param>
 /// <param name="worldTransform">World transform matrix</param>
 public Flag(ActionGame game, Model model, PositionInTown position, double azimuth, Matrix worldTransform)
     : base(game, ActionDistance, model, position, azimuth, worldTransform)
 {
 }
예제 #44
0
 public TakeBoxOperation(ActionGame game, Box box)
     : base(game)
 {
     this.box = box;
 }
예제 #45
0
파일: Camera.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new camera component.
 /// </summary>
 /// <param name="game">The game it is situated in</param>
 public Camera(ActionGame game)
     : base(game)
 {
 }
예제 #46
0
파일: ToolBox.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new toolbox
 /// </summary>
 /// <param name="toolInside">The tool instance inside</param>
 /// <param name="game">The game</param>
 /// <param name="takeSound">The taking sound</param>
 /// <param name="model">Model of the box</param>
 /// <param name="position">Position of the box</param>
 /// <param name="world">World transformation matrix</param>
 public ToolBox(Tool toolInside, ActionGame game, SoundEffect takeSound, Model model, PositionInTown position, Matrix world)
     : base(game, takeSound, model, position, world)
 {
     tool = toolInside;
 }
예제 #47
0
파일: ToolBox.cs 프로젝트: havri/ActionGame
 /// <summary>
 /// Creates a new toolbox
 /// </summary>
 /// <param name="toolInside">The tool instance inside</param>
 /// <param name="game">The game</param>
 /// <param name="takeSound">The taking sound</param>
 /// <param name="model">Model of the box</param>
 /// <param name="position">Position of the box</param>
 /// <param name="world">World transformation matrix</param>
 public ToolBox(Tool toolInside, ActionGame game, SoundEffect takeSound, Model model, PositionInTown position, Matrix world)
     : base(game, takeSound, model, position, world)
 {
     tool = toolInside;
 }
예제 #48
0
 public CaptureFlagOperation(ActionGame game, int quarterIndex)
     : base(game, game.Town.Quarters[quarterIndex].Flag)
 {
     this.quarterIndex = quarterIndex;
 }