예제 #1
0
파일: Form1.cs 프로젝트: GA23187/rpg
        public int mc_mod = 0;                //0—nomal,1—event
        private void Form1_Load(object sender, EventArgs e)
        {
            //光标
            mc_nomal = new Bitmap(@"ui/mc_1.png");
            mc_nomal.SetResolution(96, 96);
            mc_event = new Bitmap(@"ui/mc_2.png");
            mc_event.SetResolution(96, 96);

            Define.define(player, npc, map);
            Map.change_map(map, player, npc, 0, 30, 500, 1, music_player);

            /*           Button b = new Button();
             *         b.click_event += new Button.Click_event(tryevent);
             *         b.click();
             */

            Title.init();
            Title.show();

            Message.init();
            StatusMenu.init();

            Shop.init();

            // Fight.start(new int[] {0,0,-1},"fight/f_scene.png",1,0,1,1,100);            //指定2个id=0的敌人
            Fight.init();
            Save.init();
        }
예제 #2
0
        /// <summary>
        /// Constructor of class.
        /// </summary>
        /// <param name="game">The instance of game that is running.</param>
        /// <param name="player">The owner of the unit.</param>
        /// <param name="position">The position of the unit.</param>
        /// <param name="attributes">The attributes of the unit.</param>
        /// <param name="orientation">The orientation of the unit.</param>
        /// <param name="texture">The texture of the unit.</param>
        /// <param name="name">The name of unit.</param>
        public Unit(Game game, Player player, Vector2 position, Attributes attributes, Orientation orientation, Texture2D texture, String name)
            : base(game)
        {
            // Set the properties.
            this.PositionField    = position;
            this.AttributesField  = attributes;
            this.OrientationField = orientation;
            this.TextureField     = texture;
            this.PlayerField      = player;
            this.NameField        = name;

            // Set the logic properties.
            this.LifeField       = this.Attributes.MaximumLife;
            this.ManaField       = this.Attributes.MaximumMana;
            this.TimeField       = 0;
            this.IsSelectedField = false;

            // Load the actions
            this.AttacksField = AttackManager.Instance.Construct(this);
            this.SkillsField  = SkillManager.Instance.Construct(this);
            this.ItemsField   = ItemManager.Instance.Construct(this);

            // Create the menus.
            this.ActionManagerField = new ActionManager(game, this);
            this.StatusMenuField    = new StatusMenu(game, this);

            InputManager.Instance.CursorDown += new EventHandler <CursorDownArgs>(CursorDown_Handler);
        }
예제 #3
0
    void Awake()
    {
        instance = this;

        for (int i = 0; i < buttons.Length; i++)
        {
            int x = i;
            buttons[i].onClick.AddListener(new UnityEngine.Events.UnityAction(() => { SwitchSections(x); }));
        }
    }
예제 #4
0
    void Start()
    {
        menus           = new List <StatusMenu>(battleController.GetNumHeroes());
        battleHeroNames = battleController.GetHeroNames();
        menusEnabled    = null;

        // Instantiate a status menu for each hero in this battle
        for (var i = 0; i < battleController.GetNumHeroes(); ++i)
        {
            GameObject statusMenu = Instantiate(statusMenuPrefab, container.transform);
            statusMenu.transform.localPosition = new Vector3(statusMenu.transform.localPosition.x, statusMenu.transform.localPosition.y - (i * yOffset));

            StatusMenu status = new StatusMenu();
            status.heroID           = battleController.GetNthHeroID(i);
            status.rootTransform    = statusMenu.transform;
            status.nameText         = statusMenu.transform.Find("Name").GetComponent <TextMeshProUGUI>();
            status.hpText           = statusMenu.transform.Find("HPText").GetComponent <TextMeshProUGUI>();
            status.hpValue          = statusMenu.transform.Find("HPValue").GetComponent <TextMeshProUGUI>();
            status.healthBar        = statusMenu.transform.Find("HealthBar").GetComponent <RectTransform>();
            status.missingHealthBar = status.healthBar.transform.Find("MissingHealthBar").GetComponent <RectTransform>();

            if (battleController.GetCombatantName(status.heroID).ToLower() == "jack")
            {
                status.isProtagonist = true;

                // Handle Jack's separate Calm and Strife resources
                status.calmVal = statusMenu.transform.Find("JackCalmValue").GetComponent <TextMeshProUGUI>();
                statusMenu.transform.Find("JackCalmValue").gameObject.SetActive(true);
                status.strifeVal = statusMenu.transform.Find("JackStrifeValue").GetComponent <TextMeshProUGUI>();
                statusMenu.transform.Find("JackStrifeValue").gameObject.SetActive(true);
                statusMenu.transform.Find("ResourceValue").gameObject.SetActive(false);
            }
            else
            {
                status.isProtagonist = false;

                // Other characters only have a single resource value label
                status.resourceVal = statusMenu.transform.Find("ResourceValue").GetComponent <TextMeshProUGUI>();
            }
            status.calmBar          = statusMenu.transform.Find("CalmBar").GetComponent <RectTransform>();
            status.missingCalmBar   = status.calmBar.transform.Find("MissingCalmBar").GetComponent <RectTransform>();
            status.strifeBar        = statusMenu.transform.Find("StrifeBar").GetComponent <RectTransform>();
            status.missingStrifeBar = status.strifeBar.transform.Find("MissingStrifeBar").GetComponent <RectTransform>();

            status.startTime = 0f;
            status.startPos  = statusMenu.transform.localPosition;
            status.endPos    = statusMenu.transform.localPosition + new Vector3(ANIM_DELTA_X, 0f);
            status.expanded  = false;
            status.SetEnabled(false);
            menus.Add(status);

            // Set the text to our hero name
            status.nameText.SetText(battleController.GetCombatantName(status.heroID).ToUpper());
        }
    }
예제 #5
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
     }
 }
예제 #6
0
        public override void OnDisconnect(NetworkSystem system, NetworkConnection connection, NetIncomingMessage message)
        {
            string reason = message.PeekString();

            if ("MANUAL_DISCONNECT".Equals(reason))
            {
                return;
            }
            StatusMenu statusMenu = GameManager.Instance.menus.SelectMenu <StatusMenu>(1);

            statusMenu.SetStatus("Disconnected", reason);
            statusMenu.SetAction("Main Menu", () => StatusMenu.GoToMain());
        }
예제 #7
0
    private void Start()
    {
        //When we start the game turn everything off
        eventSys     = EventSystem.current;
        dataRetainer = DataRetainer.instance;
        inventoryMenu.SetActive(false);
        equipmentMenu.SetActive(false);
        statusMenu.SetActive(false);
        pauseGameMenu.SetActive(false);

        statusMenuScript    = StatusMenu.instance;
        equipmentMenuScript = GetComponent <EquipmentMenu>();

        dataRetainer.ExploringInit();
    }
예제 #8
0
        public void OnStatusChange(NetConnectionStatus status)
        {
            if (status == NetConnectionStatus.InitiatedConnect)
            {
                StatusMenu statusMenu = GameManager.Instance.menus.SelectMenu <StatusMenu>(1);
                statusMenu.SetStatus("Connecting....", "");
                statusMenu.SetAction("Cancel", () =>
                {
                    _system.Client.Disconnect("MANUAL_DISCONNECT");
                    GameManager.Instance.menus.SelectMenu <UIMenu>(0);
                });
            }

            if (status == NetConnectionStatus.Connected)
            {
                _connection.SendPacket(new CPacketLoginStart(_system.Profile), NetDeliveryMethod.ReliableOrdered);
            }
        }
예제 #9
0
        public static void Menu(ORM orm)
        {
            bool check = true;

            while (check == true)
            {
                Console.WriteLine("Choose the table: \n" + "1.Addresses\n" + "2.Cars\n" + "3.DeliveryStatus\n" + "4.People\n" + "5.Types\n" + "<- Back\n");
                Console.Write(">>");
                string choice = Console.ReadLine();
                try
                {
                    switch (choice)
                    {
                    case "Addresses":
                        AddressesMenu.Show(orm);
                        break;

                    case "Cars":
                        CarsMenu.Show(orm);
                        break;

                    case "DeliveryStatus":
                        StatusMenu.Show(orm);
                        break;

                    case "People":
                        PeopleMenu.Show(orm);
                        break;

                    case "Types":
                        TypesMenu.Show(orm);
                        break;

                    case "Back":
                        check = false;
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
예제 #10
0
파일: Player.cs 프로젝트: GA23187/rpg
    //角色处于行走状态且玩家按下鼠标左键,设置目标坐标
    public static void mouse_click(Map[] map, Player[] player, Rectangle stage, MouseEventArgs e)
    {
        if (Player.status != Status.WALK)
        {
            return;
        }
        if (e.Button == MouseButtons.Left)
        {
            target_x = e.X - Map.get_map_sx(map, player, stage);
            target_y = e.Y - Map.get_map_sy(map, player, stage);

            flag_start_time = Comm.Time();
        }
        else if (e.Button == MouseButtons.Right)                 //鼠标右键弹出面板
        {
            StatusMenu.show();
            Task.block();
        }
    }
예제 #11
0
    void AddSubMenuComponent()
    {
        StatusMenu sm = gameObject.AddComponent <StatusMenu> ();

        sm.enabled = false;

        SkillMenu skm = gameObject.AddComponent <SkillMenu> ();

        skm.enabled = false;

        EquipMenu em = gameObject.AddComponent <EquipMenu> ();

        em.enabled = false;

        ItemMenu im = gameObject.AddComponent <ItemMenu> ();

        im.enabled = false;

        SaveMenu sam = gameObject.AddComponent <SaveMenu> ();

        sam.enabled = false;
    }
예제 #12
0
        /// <summary>
        /// Create the game scene
        /// </summary>
        public GameScene(GameEngine engine) : base(0, 0)
        {
            // Create all of the sub-menus
            StatusMenu    = new StatusMenu(0, 0, 15, engine.CONSOLE_HEIGHT);
            MessageMenu   = new MessageMenu(14, 50, engine.CONSOLE_WIDTH - 14, engine.CONSOLE_HEIGHT - 50);
            DungeonScreen = new DungeonScreen(16, 2, AscensionGame.DungeonWidth, AscensionGame.DungeonHeight, engine);
            InventoryMenu = new InventoryMenu(14, 0, engine.CONSOLE_WIDTH - 14, engine.CONSOLE_HEIGHT - 1, engine);
            SkillMenu     = new SkillMenu(14, 0, engine.CONSOLE_WIDTH - 14, engine.CONSOLE_HEIGHT - 1, engine);

            // Attach all of the sub-menus
            this.AttachChild("Status", StatusMenu);
            this.AttachChild("Message", MessageMenu);
            this.AttachChild("Dungeon", DungeonScreen);
            this.AttachChild("Inventory", InventoryMenu);
            this.AttachChild("Skill", SkillMenu);

            UniqueMenus = new List <string> {
                "Dungeon",
                "Message",
                "Inventory",
                "Skill"
            };
        }
예제 #13
0
 public void OnStatusButtonClicked()
 {
     StatusMenu.Show();
 }
예제 #14
0
파일: Player.cs 프로젝트: GA23187/rpg
    //-----------------------------------------------------------------
    //        操控
    //-----------------------------------------------------------------
    public static void key_ctrl(Player[] player, Map[] map, Npc[] npc, KeyEventArgs e)
    {
        Player p = player[current_player];

        if (Player.status != Status.WALK)
        {
            return;
        }
        //切换角色
        if (e.KeyCode == Keys.Tab)
        {
            key_change_player(player);
        }

        /*       //是否转向                                      //先处理转向在处理行走
         *     if (e.KeyCode == Keys.Up && p.face != 4)
         *         p.face = 4;
         *     else if (e.KeyCode == Keys.Down && p.face != 1)
         *         p.face = 1;
         *     else if (e.KeyCode == Keys.Left && p.face != 2)
         *         p.face = 2;
         *     else if (e.KeyCode == Keys.Right && p.face != 3)
         *         p.face = 3;
         *     //间隔判定
         *     if (Comm.Time() - p.last_walk_time <= p.walk_interval)
         *         return;
         *     //移动处理
         *     if (e.KeyCode == Keys.Up&&Map.can_through(map,p.x,p.y-p.speed))                                   //加上判断目标位置是否可以通行
         *         p.y = p.y - p.speed;
         *     else if (e.KeyCode == Keys.Down && Map.can_through(map, p.x, p.y + p.speed))                                   //行走速度由speed控制
         *         p.y = p.y + p.speed;
         *     else if (e.KeyCode == Keys.Left && Map.can_through(map, p.x - p.speed, p.y))
         *         p.x = p.x - p.speed;
         *     else if (e.KeyCode == Keys.Right && Map.can_through(map, p.x + p.speed, p.y))
         *         p.x = p.x + p.speed;
         *     else return;
         *     //动画帧
         *     p.anm_frame = p.anm_frame + 1;
         *     if (p.anm_frame >= int.MaxValue) p.anm_frame = 0;     //超出上限的处理
         *     //时间
         *     p.last_walk_time = Comm.Time();
         */
        //行走
        if (e.KeyCode == Keys.Up)
        {
            walk(player, map, Comm.Direction.UP);
        }
        else if (e.KeyCode == Keys.Down)
        {
            walk(player, map, Comm.Direction.DOWN);
        }
        else if (e.KeyCode == Keys.Left)
        {
            walk(player, map, Comm.Direction.LEFT);
        }
        else if (e.KeyCode == Keys.Right)
        {
            walk(player, map, Comm.Direction.RIGHT);
        }
        else if (e.KeyCode == Keys.Escape)
        {
            StatusMenu.show();
            Task.block();
        }
        //npc碰撞
        npc_collision(player, map, npc, e);
    }
예제 #15
0
    void Update()
    {
        if (battleController.UIEnabled != menusEnabled ||
            menusEnabled == null)
        {
            for (var i = 0; i < menus.Count; ++i)
            {
                menus[i].SetEnabled(battleController.UIEnabled);
            }

            menusEnabled = battleController.UIEnabled;
        }

        // Update the contents of the UI elements
        for (var i = 0; i < menus.Count; ++i)
        {
            StatusMenu menu = menus[i];

            // Get all the data we need
            int   hp    = battleController.GetCombatantHP(menu.heroID);
            int   maxHp = battleController.GetCombatantMaxHP(menu.heroID);
            Color color = battleController.GetHeroColor(menu.heroID);

            // Update the hit point numerical indicator
            menu.hpValue.SetText(hp.ToString() + " / " + maxHp.ToString());

            // Update the missing health mask
            float missingHealth     = battleController.GetCombatantMaxHP(menu.heroID) - battleController.GetCombatantHP(menu.heroID);
            float percentageMissing = missingHealth / maxHp;
            float newWidth          = percentageMissing * menu.healthBar.rect.width;
            menu.missingHealthBar.sizeDelta = new Vector2(newWidth, menu.missingHealthBar.sizeDelta.y);

            // Update the resource value numerical indicator
            if (menu.isProtagonist)
            {
                menu.calmVal.SetText(battleController.GetHeroCalm(menu.heroID).ToString());
                menu.strifeVal.SetText(battleController.GetHeroStrife(menu.heroID).ToString());
            }
            else
            {
                int currResource = battleController.GetHeroResource(menu.heroID);
                if (currResource > 0)
                {
                    menu.resourceVal.color = menu.strifeBar.GetComponent <Image>().color;
                    float newXPos = menu.strifeBar.rect.width - menu.missingStrifeBar.rect.width;
                    menu.resourceVal.rectTransform.localPosition = new Vector3(newXPos, menu.resourceVal.rectTransform.localPosition.y);
                }
                else if (currResource < 0)
                {
                    menu.resourceVal.color = menu.calmBar.GetComponent <Image>().color;
                    float newXPos = menu.missingCalmBar.rect.width - menu.calmBar.rect.width;
                    menu.resourceVal.rectTransform.localPosition = new Vector3(newXPos, menu.resourceVal.rectTransform.localPosition.y);
                }
                else
                {
                    menu.resourceVal.color = Color.white;
                }

                menu.resourceVal.SetText(Mathf.Abs(currResource).ToString());
            }
            // Update the resource masks
            float calmWidthPercentage   = (100f - battleController.GetHeroCalm(menu.heroID)) / 100f;
            float strifeWidthPercentage = (100f - battleController.GetHeroStrife(menu.heroID)) / 100f;
            float newCalmWidth          = calmWidthPercentage * menu.calmBar.sizeDelta.x;
            float newStrifeWidth        = strifeWidthPercentage * menu.strifeBar.sizeDelta.x;
            menu.missingCalmBar.sizeDelta   = new Vector2(newCalmWidth, menu.missingCalmBar.sizeDelta.y);
            menu.missingStrifeBar.sizeDelta = new Vector2(newStrifeWidth, menu.missingStrifeBar.sizeDelta.y);

            // Highlight this menu if it's the hero's turn
            if (i == battleHeroNames.IndexOf(battleController.CurrCombatantName) &&
                !battleController.IsCombatantAnimating(battleController.CurrCombatantID) &&
                battleController.State == BattleController.BattleState.PLAYERCHOICE)
            {
                // Set the colours
                menu.nameText.color = color;
                menu.hpText.color   = color;
                menu.hpValue.color  = color;
                menu.healthBar.GetComponent <Image>().color = color;

                // Lerp animate to expanded position
                if (!menu.expanded)
                {
                    menu.startTime = Time.time;
                    menu.expanded  = true;
                }
                float distCovered   = (Time.time - menu.startTime) * ANIM_SPEED;
                float journeyLength = Vector3.Distance(menu.rootTransform.localPosition, menu.endPos);
                if (journeyLength > 0f)
                {
                    float fractionOfJourney = distCovered / journeyLength;
                    menu.rootTransform.localPosition = Vector3.Lerp(menu.startPos, menu.endPos, fractionOfJourney);
                }
            }
            else
            {
                // Set the colours
                menu.nameText.color = Color.white;
                menu.hpText.color   = Color.white;
                menu.hpValue.color  = Color.white;
                menu.healthBar.GetComponent <Image>().color = Color.white;

                // Lerp to non-animated position
                if (menu.expanded)
                {
                    menu.startTime = Time.time;
                    menu.expanded  = false;
                }
                float distCovered   = (Time.time - menu.startTime) * ANIM_SPEED;
                float journeyLength = Vector3.Distance(menu.rootTransform.localPosition, menu.startPos);
                if (journeyLength > 0f)
                {
                    float fractionOfJourney = distCovered / journeyLength;
                    menu.rootTransform.localPosition = Vector3.Lerp(menu.endPos, menu.startPos, fractionOfJourney);
                }
            }
        }
    }
        void ReleaseDesignerOutlets()
        {
            if (ArduinoPortsMenu != null)
            {
                ArduinoPortsMenu.Dispose();
                ArduinoPortsMenu = null;
            }

            if (Exit != null)
            {
                Exit.Dispose();
                Exit = null;
            }

            if (FiftyMinutes != null)
            {
                FiftyMinutes.Dispose();
                FiftyMinutes = null;
            }

            if (FortyMinutes != null)
            {
                FortyMinutes.Dispose();
                FortyMinutes = null;
            }

            if (SixtyMinutes != null)
            {
                SixtyMinutes.Dispose();
                SixtyMinutes = null;
            }

            if (StatusMenu != null)
            {
                StatusMenu.Dispose();
                StatusMenu = null;
            }

            if (Stop != null)
            {
                Stop.Dispose();
                Stop = null;
            }

            if (TenMinutes != null)
            {
                TenMinutes.Dispose();
                TenMinutes = null;
            }

            if (ThirtyMinutes != null)
            {
                ThirtyMinutes.Dispose();
                ThirtyMinutes = null;
            }

            if (TwentyMinutes != null)
            {
                TwentyMinutes.Dispose();
                TwentyMinutes = null;
            }

            if (Test != null)
            {
                Test.Dispose();
                Test = null;
            }
        }
예제 #17
0
    private int[] healthDifference = new int[4]; //When we change the equipment we remember the damage each player took before changing

    private void Start()
    {
        statusMenu   = StatusMenu.instance;
        dataRetainer = DataRetainer.instance;
    }