Ejemplo n.º 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;
        }
    }
Ejemplo n.º 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;
        }
    }
Ejemplo n.º 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();
    }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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();
    }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
    }
Ejemplo n.º 8
0
 /// <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;
 }
Ejemplo n.º 9
0
 /// <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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
    }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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;
        }
    }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 17
0
 /// <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;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Creates a new camera component.
 /// </summary>
 /// <param name="game">The game it is situated in</param>
 public Camera(ActionGame game)
     : base(game)
 {
 }
Ejemplo n.º 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());
        }
Ejemplo n.º 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();
    }
Ejemplo n.º 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;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Creates a new operation.
 /// </summary>
 /// <param name="game">The game</param>
 public Operation(ActionGame game)
 {
     this.game = game;
 }
Ejemplo n.º 23
0
 /// <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)
 {
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Creates a new operation.
 /// </summary>
 /// <param name="game">The game</param>
 public Operation(ActionGame game)
 {
     this.game = game;
 }
Ejemplo n.º 25
0
 public ContentRepository(ActionGame game)
 {
     this.game = game;
 }
Ejemplo n.º 26
0
 public ContentRepository(ActionGame game)
 {
     this.game = game;
 }
Ejemplo n.º 27
0
 public KillPlayerOperation(ActionGame game)
     : base(game)
 {
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Creates a new sound playing component.
 /// </summary>
 /// <param name="game"></param>
 public SoundPlayer(ActionGame game)
 {
     this.game = game;
 }
Ejemplo n.º 29
0
 /// <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;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Creates a new sound playing component.
 /// </summary>
 /// <param name="game"></param>
 public SoundPlayer(ActionGame game)
 {
     this.game = game;
 }
Ejemplo n.º 31
0
        /// <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];
        }
Ejemplo n.º 32
0
 /// <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)
 {
 }
Ejemplo n.º 33
0
 /// <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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 35
0
 public CaptureFlagOperation(ActionGame game, int quarterIndex)
     : base(game, game.Town.Quarters[quarterIndex].Flag)
 {
     this.quarterIndex = quarterIndex;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 37
0
 /// <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;
 }
Ejemplo n.º 38
0
 public KillPlayerOperation(ActionGame game)
     : base(game)
 {
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 40
0
        /// <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];
        }
Ejemplo n.º 41
0
 public TakeBoxOperation(ActionGame game, Box box)
     : base(game)
 {
     this.box = box;
 }
Ejemplo n.º 42
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;
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 44
0
 public TakeBoxOperation(ActionGame game, Box box)
     : base(game)
 {
     this.box = box;
 }
Ejemplo n.º 45
0
 /// <summary>
 /// Creates a new camera component.
 /// </summary>
 /// <param name="game">The game it is situated in</param>
 public Camera(ActionGame game)
     : base(game)
 {
 }
Ejemplo n.º 46
0
 /// <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;
 }
Ejemplo n.º 47
0
 /// <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;
 }
Ejemplo n.º 48
0
 public CaptureFlagOperation(ActionGame game, int quarterIndex)
     : base(game, game.Town.Quarters[quarterIndex].Flag)
 {
     this.quarterIndex = quarterIndex;
 }