Ejemplo n.º 1
0
    public void RegisterButton_OnClick()
    {
        string username = RegisterUserName.text;
        string password = RegisterPassword.text;
        string confirm  = ConfirmPassword.text;

        if (username == string.Empty || password == string.Empty)
        {
            return;
        }
        if (confirm != password)
        {
            return;
        }

        Network.Enqueue(new C.NewAccount
        {
            AccountID      = username,
            Password       = password,
            EMailAddress   = "*****@*****.**",
            BirthDate      = DateTime.Now,
            UserName       = "******",
            SecretQuestion = "na",
            SecretAnswer   = "na"
        });
    }
Ejemplo n.º 2
0
 void Start()
 {
     ScrollBar.size = 0.4f;
     Network.Enqueue(new C.RequestMapInformation {
     });
     Inventory.gameObject.SetActive(false);
 }
Ejemplo n.º 3
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Return))
        {
            if (ChatBar.gameObject.activeSelf)
            {
                if (ChatBar.text.Length > 0)
                {
                    Network.Enqueue(new C.Chat()
                    {
                        Message = ChatBar.text
                    });
                }
                ChatBar.text = string.Empty;
                ChatBar.gameObject.SetActive(false);
            }
            else
            {
                ChatBar.gameObject.SetActive(true);
                ChatBar.Select();
            }
        }

        if ((Input.GetMouseButton(0) || Input.GetMouseButton(1)) && !eventSystem.IsPointerOverGameObject())
        {
            GameManager.CheckMouseInput();
        }

        if (SelectedItemImage.gameObject.activeSelf)
        {
            SelectedItemImage.transform.position = Input.mousePosition;
            SelectedItemImage.transform.SetAsLastSibling();
        }
    }
Ejemplo n.º 4
0
 void StartGame()
 {
     Network.Enqueue(new C.StartGame()
     {
         CharacterIndex = selectedCharacter.Index
     });
 }
Ejemplo n.º 5
0
    public void MapChanged(S.MapChanged p)
    {
        foreach (var ob in ObjectList.ToArray())
        {
            Destroy(ob.Value.gameObject);
        }
        ObjectList.Clear();

        ClearAction();
        User.Player.CurrentLocation = new Vector2(p.Location.X, p.Location.Y);

        if (p.SceneName != CurrentScene.gameObject.scene.name)
        {
            FindObjectOfType <LoadScreenManager>().ChangeScene(p.SceneName, p.FileName, CurrentScene.gameObject.scene);
        }
        else
        {
            if (p.FileName != CurrentScene.FileName)
            {
                CurrentScene.LoadMap(p.FileName);
            }
            Network.Enqueue(new C.MapChanged {
            });
            UserGameObject.transform.position = CurrentScene.Cells[(int)User.Player.CurrentLocation.x, (int)User.Player.CurrentLocation.y].position;
        }
    }
Ejemplo n.º 6
0
 public void LogOut_Click()
 {
     MessageBox.Show($"Return to Character Select?", true, true);
     MessageBox.OK += () =>
     {
         Network.Enqueue(new C.LogOut());
         FindObjectOfType <LoadScreenManager>().Show();
     };
 }
Ejemplo n.º 7
0
 public void OnLoaded()
 {
     audioSource.Play();
     SelectCharacterBox.SetActive(true);
     LogOutButton.gameObject.SetActive(true);
     GameManager.gameStage = GameStage.Select;
     Network.Enqueue(new C.RequestCharacters {
     });
 }
Ejemplo n.º 8
0
 public void LogoutButton_OnClick()
 {
     MessageBox.Show($"Return to Login?", true, true);
     MessageBox.OK += () =>
     {
         Network.Enqueue(new C.Logout()
         {
         });
     };
 }
Ejemplo n.º 9
0
 public void ChangeAttackMode(int amode)
 {
     if (amode >= Enum.GetNames(typeof(AttackMode)).Length)
     {
         return;
     }
     Network.Enqueue(new C.ChangeAMode()
     {
         Mode = (AttackMode)amode
     });
 }
Ejemplo n.º 10
0
    public void NPCTextButton(string LinkId)
    {
        if (LinkId == "@exit")
        {
            NPCDialog.gameObject.SetActive(false);
            return;
        }

        Network.Enqueue(new C.CallNPC {
            ObjectID = NPCID, Key = "[" + LinkId + "]"
        });
        GameManager.InputDelay = Time.time + 0.5f;
    }
Ejemplo n.º 11
0
    public void Create_Click()
    {
        if (NameInput.text.Length < 5)
        {
            ShowMessageBox("Name must be minimum 5 characters");
            return;
        }

        Network.Enqueue(new C.NewCharacter
        {
            Name   = NameInput.text,
            Class  = selectedClass,
            Gender = selectedGender
        });
    }
Ejemplo n.º 12
0
    private IEnumerator BeginLoad(string sceneName)
    {
        operation = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);

        while (!operation.isDone)
        {
            UpdateProgressUI(operation.progress);
            yield return(null);
        }

        UpdateProgressUI(operation.progress);
        operation = null;
        canvas.gameObject.SetActive(false);
        Network.Enqueue(new C.MapLoaded {
        });
    }
Ejemplo n.º 13
0
    public void DeleteCharacter_OnClick()
    {
        if (selectedCharacter == null)
        {
            return;
        }

        MessageBox.Show($"Delete {selectedCharacter.Name}?", true, true);
        MessageBox.OK += () =>
        {
            Network.Enqueue(new C.DeleteCharacter()
            {
                CharacterIndex = selectedCharacter.Index
            });
        };
    }
Ejemplo n.º 14
0
    private IEnumerator BeginLoad(string sceneName, string fileName)
    {
        AsyncOperation operation = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);

        while (!operation.isDone)
        {
            Network.Process();
            float progress = Mathf.Clamp01(operation.progress / .9f);
            slider.value = progress;
            yield return(null);
        }

        GameManager.CurrentScene.LoadMap(fileName);
        slider.value = operation.progress;
        operation    = null;
        Hide();
        Network.Enqueue(new C.MapLoaded {
        });
    }
Ejemplo n.º 15
0
    public void LoginButton_OnClick()
    {
        string username = UserName.text;
        string password = Password.text;

        if (username == string.Empty || password == string.Empty)
        {
            return;
        }

        Network.Enqueue(new C.Login
        {
            AccountID = username,
            Password  = password
        });

        UserName.text = string.Empty;
        Password.text = string.Empty;
    }
Ejemplo n.º 16
0
    // Start is called before the first frame update
    void Start()
    {
        gameStage = GameStage.Login;

        networkInfo = new NetworkInfo();
        string fileName = Application.dataPath + "/Settings.json";
        string json     = string.Empty;

        if (File.Exists(fileName))
        {
            json = File.ReadAllText(fileName);
        }
        else
        {
            json = JsonUtility.ToJson(networkInfo);
            File.WriteAllText(fileName, json);
        }

        networkInfo = JsonUtility.FromJson <NetworkInfo>(json);
        Network.Connect();
    }
Ejemplo n.º 17
0
    public void MapChanged(S.MapChanged p)
    {
        ClearObjects();
        ClearAction();
        User.Player.CurrentLocation = new Vector2Int(p.Location.X, p.Location.Y);

        if (p.SceneName != CurrentScene.gameObject.scene.name)
        {
            FindObjectOfType <LoadScreenManager>().ChangeScene(p.SceneName, p.FileName, CurrentScene.gameObject.scene);
        }
        else
        {
            if (p.FileName != CurrentScene.FileName)
            {
                CurrentScene.LoadMap(p.FileName);
            }
            Network.Enqueue(new C.MapChanged {
            });
            UserGameObject.transform.position = CurrentScene.Cells[User.Player.CurrentLocation.x, User.Player.CurrentLocation.y].position;
        }
    }
Ejemplo n.º 18
0
    public void OnLoaded()
    {
        activeLocation   = GameObject.Find("ActiveLocation");
        inactiveLocation = GameObject.Find("InactiveLocation");
        previewLocation  = GameObject.Find("PreviewLocation");
        loginCamera      = GameObject.Find("LoginCamera");
        LoginPosition    = GameObject.Find("LoginCameraPosition").transform;
        CharSelPosition  = GameObject.Find("CharSelCameraPosition").transform;

        loginCamera.gameObject.SetActive(false);
        loginCamera.transform.SetPositionAndRotation(CharSelPosition.position, CharSelPosition.rotation);
        loginCamera.gameObject.SetActive(true);
        loginCamera.GetComponent <CameraFade>().Reset();
        loginCamera.GetComponent <CameraFade>().CurrentCurve = loginCamera.GetComponent <CameraFade>().FadeInCurve;
        audioSource.Play();
        Camera.main.fieldOfView = 50;
        SelectCharacterBox.SetActive(true);
        LogOutButton.gameObject.SetActive(true);
        GameManager.gameStage = GameStage.Select;
        Network.Enqueue(new C.RequestCharacters {
        });
        FindObjectOfType <LoadScreenManager>().Hide();
    }
Ejemplo n.º 19
0
    public void ChangePasswordButton_OnClick()
    {
        string username    = ChangeUserName.text;
        string password    = ChangeCurrentPassword.text;
        string newpassword = ChangeNewPassword.text;
        string confirm     = ChangeConfirmPassword.text;

        if (username == string.Empty || password == string.Empty || newpassword == string.Empty)
        {
            return;
        }
        if (confirm != newpassword)
        {
            return;
        }

        Network.Enqueue(new C.ChangePassword
        {
            AccountID       = username,
            CurrentPassword = password,
            NewPassword     = newpassword
        });
    }
Ejemplo n.º 20
0
    private IEnumerator BeginChange(string sceneName, string fileName, Scene oldScene)
    {
        GameManager.CurrentScene = null;
        AsyncOperation unloadoperation = SceneManager.UnloadSceneAsync(oldScene);
        AsyncOperation loadoperation   = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);

        while (!unloadoperation.isDone || !loadoperation.isDone)
        {
            Network.Process();
            float progress = Mathf.Clamp01(loadoperation.progress / .9f) + Mathf.Clamp01(unloadoperation.progress / .9f);
            progress    /= 2f;
            slider.value = progress;
            yield return(null);
        }

        GameManager.CurrentScene.LoadMap(fileName);
        GameManager.UserGameObject.transform.position = GameManager.CurrentScene.Cells[(int)GameManager.User.Player.CurrentLocation.x, (int)GameManager.User.Player.CurrentLocation.y].position;
        slider.value    = 1f;
        loadoperation   = null;
        unloadoperation = null;
        Hide();
        Network.Enqueue(new C.MapChanged {
        });
    }
Ejemplo n.º 21
0
    private void MoveItem()
    {
        if (GridType == MirGridType.BuyBack || GridType == MirGridType.DropPanel || GridType == MirGridType.Inspect || GridType == MirGridType.TrustMerchant || GridType == MirGridType.Craft)
        {
            return;
        }

        if (GameScene.SelectedCell != null)
        {
            if (GameScene.SelectedCell.Item == null || GameScene.SelectedCell == this)
            {
                GameScene.SelectedCell = null;
                return;
            }

            switch (GridType)
            {
                #region To Inventory
            case MirGridType.Inventory:     // To Inventory
                switch (GameScene.SelectedCell.GridType)
                {
                    #region From Inventory
                case MirGridType.Inventory:         //From Invenotry
                    if (Item != null)
                    {
                        /*if (CMain.Ctrl)
                         * {
                         *  MirMessageBox messageBox = new MirMessageBox("Do you want to try and combine these items?", MirMessageBoxButtons.YesNo);
                         *  messageBox.YesButton.Click += (o, e) =>
                         *  {
                         *      //Combine
                         *      Network.Enqueue(new C.CombineItem { IDFrom = GameScene.SelectedCell.Item.UniqueID, IDTo = Item.UniqueID });
                         *      Locked = true;
                         *      GameScene.SelectedCell.Locked = true;
                         *      GameScene.SelectedCell = null;
                         *  };
                         *
                         *  messageBox.Show();
                         *  return;
                         * }*/

                        if (GameScene.SelectedCell.Item.Info == Item.Info && Item.Count < Item.Info.StackSize)
                        {
                            //Merge
                            Network.Enqueue(new C.MergeItem {
                                GridFrom = GameScene.SelectedCell.GridType, GridTo = GridType, IDFrom = GameScene.SelectedCell.Item.UniqueID, IDTo = Item.UniqueID
                            });

                            Locked = true;
                            GameScene.SelectedCell.Locked = true;
                            GameScene.SelectedCell        = null;
                            return;
                        }
                    }

                    Network.Enqueue(new C.MoveItem {
                        Grid = GridType, From = GameScene.SelectedCell.ItemSlot, To = ItemSlot
                    });

                    Locked = true;
                    GameScene.SelectedCell.Locked = true;
                    GameScene.SelectedCell        = null;
                    return;

                    #endregion

                    #region From Equipment
                case MirGridType.Equipment:         //From Equipment
                    if (Item != null && GameScene.SelectedCell.Item.Info.Type == ItemType.Amulet)
                    {
                        if (GameScene.SelectedCell.Item.Info == Item.Info && Item.Count < Item.Info.StackSize)
                        {
                            Network.Enqueue(new C.MergeItem {
                                GridFrom = GameScene.SelectedCell.GridType, GridTo = GridType, IDFrom = GameScene.SelectedCell.Item.UniqueID, IDTo = Item.UniqueID
                            });

                            Locked = true;
                            GameScene.SelectedCell.Locked = true;
                            GameScene.SelectedCell        = null;
                            return;
                        }
                    }

                    if (!CanRemoveItem(GameScene.SelectedCell.Item))
                    {
                        GameScene.SelectedCell = null;
                        return;
                    }
                    if (Item == null)
                    {
                        Network.Enqueue(new C.RemoveItem {
                            Grid = GridType, UniqueID = GameScene.SelectedCell.Item.UniqueID, To = ItemSlot
                        });

                        Locked = true;
                        GameScene.SelectedCell.Locked = true;
                        GameScene.SelectedCell        = null;
                        return;
                    }

                    for (int x = 6; x < ItemArray.Length; x++)
                    {
                        if (ItemArray[x] == null)
                        {
                            Network.Enqueue(new C.RemoveItem {
                                Grid = GridType, UniqueID = GameScene.SelectedCell.Item.UniqueID, To = x
                            });

                            MirItemCell temp = x < GameManager.User.BeltIdx ? GameScene.BeltCells[x] : GameScene.Inventory.Cells[x - GameManager.User.BeltIdx];

                            if (temp != null)
                            {
                                temp.Locked = true;
                            }
                            GameScene.SelectedCell.Locked = true;
                            GameScene.SelectedCell        = null;
                            return;
                        }
                    }
                    break;
                    #endregion
                }
                break;
                #endregion

                #region To Equipment
            case MirGridType.Equipment:     //To Equipment

                if (GameScene.SelectedCell.GridType != MirGridType.Inventory && GameScene.SelectedCell.GridType != MirGridType.Storage)
                {
                    return;
                }


                if (Item != null && GameScene.SelectedCell.Item.Info.Type == ItemType.Amulet)
                {
                    if (GameScene.SelectedCell.Item.Info == Item.Info && Item.Count < Item.Info.StackSize)
                    {
                        Network.Enqueue(new C.MergeItem {
                            GridFrom = GameScene.SelectedCell.GridType, GridTo = GridType, IDFrom = GameScene.SelectedCell.Item.UniqueID, IDTo = Item.UniqueID
                        });

                        Locked = true;
                        GameScene.SelectedCell.Locked = true;
                        GameScene.SelectedCell        = null;
                        return;
                    }
                }

                if (CorrectSlot(GameScene.SelectedCell.Item))
                {
                    if (CanWearItem(GameScene.SelectedCell.Item))
                    {
                        Network.Enqueue(new C.EquipItem {
                            Grid = GameScene.SelectedCell.GridType, UniqueID = GameScene.SelectedCell.Item.UniqueID, To = ItemSlot
                        });
                        Locked = true;
                        GameScene.SelectedCell.Locked = true;
                    }
                    GameScene.SelectedCell = null;
                }
                return;

                #endregion
            }

            return;
        }

        if (Item != null)
        {
            GameScene.SelectedCell = this;
        }
    }
Ejemplo n.º 22
0
    public void UseItem()
    {
        if (Locked || GridType == MirGridType.Inspect || GridType == MirGridType.TrustMerchant || GridType == MirGridType.GuildStorage || GridType == MirGridType.Craft)
        {
            return;
        }


        //if (MapObject.User.RidingMount && Item.Info.Type != ItemType.Scroll && Item.Info.Type != ItemType.Potion && Item.Info.Type != ItemType.Torch) return;

        if (GridType == MirGridType.BuyBack)
        {
            //BuyItem();
            return;
        }

        if (GridType == MirGridType.Equipment || GridType == MirGridType.Mount || GridType == MirGridType.Fishing)
        {
            RemoveItem();
            return;
        }

        if ((GridType != MirGridType.Inventory && GridType != MirGridType.Storage) || Item == null || !CanUseItem() || GameScene.SelectedCell == this)
        {
            return;
        }

        if ((Item.SoulBoundId != -1) && (User.Player.ObjectID != Item.SoulBoundId))
        {
            return;
        }
        switch (Item.Info.Type)
        {
        case ItemType.Weapon:
            if (GameScene.EquipmentCells[(int)EquipmentSlot.Weapon].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.Weapon
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.Weapon].Locked = true;
                Locked = true;
            }
            break;

        case ItemType.Armour:
            if (GameScene.EquipmentCells[(int)EquipmentSlot.Armour].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.Armour
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.Armour].Locked = true;
                Locked = true;
            }
            break;

        case ItemType.Helmet:
            if (GameScene.EquipmentCells[(int)EquipmentSlot.Helmet].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.Helmet
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.Helmet].Locked = true;
                Locked = true;
            }
            break;

        case ItemType.Necklace:
            if (GameScene.EquipmentCells[(int)EquipmentSlot.Necklace].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.Necklace
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.Necklace].Locked = true;
                Locked = true;
            }
            break;

        case ItemType.Bracelet:
            if ((GameScene.EquipmentCells[(int)EquipmentSlot.BraceletR].Item == null || GameScene.EquipmentCells[(int)EquipmentSlot.BraceletR].Item.Info.Type == ItemType.Amulet) && GameScene.EquipmentCells[(int)EquipmentSlot.BraceletR].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.BraceletR
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.BraceletR].Locked = true;
                Locked = true;
            }
            else if (GameScene.EquipmentCells[(int)EquipmentSlot.BraceletL].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.BraceletL
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.BraceletL].Locked = true;
                Locked = true;
            }
            break;

        case ItemType.Ring:
            if (GameScene.EquipmentCells[(int)EquipmentSlot.RingR].Item == null && GameScene.EquipmentCells[(int)EquipmentSlot.RingR].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.RingR
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.RingR].Locked = true;
                Locked = true;
            }
            else if (GameScene.EquipmentCells[(int)EquipmentSlot.RingL].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.RingL
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.RingL].Locked = true;
                Locked = true;
            }
            break;

        case ItemType.Amulet:
            //if (Item.Info.Shape == 0) return;

            if (GameScene.EquipmentCells[(int)EquipmentSlot.Amulet].Item != null && Item.Info.Type == ItemType.Amulet)
            {
                if (GameScene.EquipmentCells[(int)EquipmentSlot.Amulet].Item.Info == Item.Info && GameScene.EquipmentCells[(int)EquipmentSlot.Amulet].Item.Count < GameScene.EquipmentCells[(int)EquipmentSlot.Amulet].Item.Info.StackSize)
                {
                    Network.Enqueue(new C.MergeItem {
                        GridFrom = GridType, GridTo = MirGridType.Equipment, IDFrom = Item.UniqueID, IDTo = GameScene.EquipmentCells[(int)EquipmentSlot.Amulet].Item.UniqueID
                    });

                    Locked = true;
                    return;
                }
            }

            if (GameScene.EquipmentCells[(int)EquipmentSlot.Amulet].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.Amulet
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.Amulet].Locked = true;
                Locked = true;
            }
            break;

        case ItemType.Belt:
            if (GameScene.EquipmentCells[(int)EquipmentSlot.Belt].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.Belt
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.Belt].Locked = true;
                Locked = true;
            }
            break;

        case ItemType.Boots:
            if (GameScene.EquipmentCells[(int)EquipmentSlot.Boots].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.Boots
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.Boots].Locked = true;
                Locked = true;
            }
            break;

        case ItemType.Stone:
            if (GameScene.EquipmentCells[(int)EquipmentSlot.Stone].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.Stone
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.Stone].Locked = true;
                Locked = true;
            }
            break;

        case ItemType.Torch:
            if (GameScene.EquipmentCells[(int)EquipmentSlot.Torch].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.Torch
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.Torch].Locked = true;
                Locked = true;
            }
            break;

        case ItemType.Potion:
        case ItemType.Scroll:
        case ItemType.Book:
        case ItemType.Food:
        case ItemType.Script:
        case ItemType.Pets:
        case ItemType.Transform:
            if (CanUseItem() && GridType == MirGridType.Inventory)
            {
                if (Time.time < GameScene.UseItemTime)
                {
                    return;
                }
                Network.Enqueue(new C.UseItem {
                    UniqueID = Item.UniqueID
                });

                if (Item.Count == 1 && ItemSlot < 6)
                {
                    for (int i = User.BeltIdx; i < User.Inventory.Length; i++)
                    {
                        if (ItemArray[i] != null && ItemArray[i].Info == Item.Info)
                        {
                            Network.Enqueue(new C.MoveItem {
                                Grid = MirGridType.Inventory, From = i, To = ItemSlot
                            });
                            GameScene.Inventory.Cells[i - User.BeltIdx].Locked = true;
                            break;
                        }
                    }
                }

                Locked = true;
            }
            break;

        case ItemType.Mount:
            if (GameScene.EquipmentCells[(int)EquipmentSlot.Mount].CanWearItem(Item))
            {
                Network.Enqueue(new C.EquipItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = (int)EquipmentSlot.Mount
                });
                GameScene.EquipmentCells[(int)EquipmentSlot.Mount].Locked = true;
                Locked = true;
            }
            break;

        case ItemType.Reins:
        case ItemType.Bells:
        case ItemType.Ribbon:
        case ItemType.Saddle:
        case ItemType.Mask:
        case ItemType.Hook:
        case ItemType.Float:
        case ItemType.Bait:
        case ItemType.Finder:
        case ItemType.Reel:
            //UseSlotItem();
            break;
        }

        GameScene.UseItemTime = Time.time + 0.3f;
        PlayItemSound();
    }
Ejemplo n.º 23
0
    public void RemoveItem()
    {
        int count = 0;

        for (int i = 0; i < User.Inventory.Length; i++)
        {
            MirItemCell itemCell = i < User.BeltIdx ? GameScene.BeltCells[i] : GameScene.Inventory.Cells[i - User.BeltIdx];
            if (itemCell.Item == null)
            {
                count++;
            }
        }

        if (Item == null || count < 1 /*|| (User.RidingMount && Item.Info.Type != ItemType.Torch)*/)
        {
            return;
        }

        if (Item.Info.StackSize > 1)
        {
            UserItem item = null;

            for (int i = 0; i < User.Inventory.Length; i++)
            {
                MirItemCell itemCell = i < User.BeltIdx ? GameScene.BeltCells[i] : GameScene.Inventory.Cells[i - User.BeltIdx];

                if (itemCell.Item == null || itemCell.Item.Info != Item.Info)
                {
                    continue;
                }

                item = itemCell.Item;
            }

            if (item != null && ((item.Count + Item.Count) <= item.Info.StackSize))
            {
                //Merge.
                Network.Enqueue(new C.MergeItem {
                    GridFrom = GridType, GridTo = MirGridType.Inventory, IDFrom = Item.UniqueID, IDTo = item.UniqueID
                });

                Locked = true;

                PlayItemSound();
                return;
            }
        }


        for (int i = 0; i < User.Inventory.Length; i++)
        {
            MirItemCell itemCell = null;

            if (Item.Info.Type == ItemType.Amulet)
            {
                itemCell = i < User.BeltIdx ? GameScene.BeltCells[i] : GameScene.Inventory.Cells[i - User.BeltIdx];
            }
            else
            {
                itemCell = i < (User.Inventory.Length - User.BeltIdx) ? GameScene.Inventory.Cells[i] : GameScene.BeltCells[i - User.Inventory.Length];
            }

            if (itemCell.Item != null)
            {
                continue;
            }

            if (GridType != MirGridType.Equipment)
            {
                Network.Enqueue(new C.RemoveSlotItem {
                    Grid = GridType, UniqueID = Item.UniqueID, To = itemCell.ItemSlot, GridTo = MirGridType.Inventory
                });
            }
            else
            {
                Network.Enqueue(new C.RemoveItem {
                    Grid = MirGridType.Inventory, UniqueID = Item.UniqueID, To = itemCell.ItemSlot
                });
            }

            Locked = true;

            PlayItemSound();
            break;
        }
    }
Ejemplo n.º 24
0
    public override void SetAction()
    {
        if (this == GameManager.User.Player && GameScene.QueuedAction != null)
        {
            ActionFeed.Clear();
            ActionFeed.Add(GameScene.QueuedAction);
            GameScene.QueuedAction = null;
        }

        if (ActionFeed.Count == 0)
        {
            CurrentAction = MirAction.Standing;
        }
        else
        {
            if (this == GameManager.User.Player && Time.time < GameManager.NextAction)
            {
                return;
            }

            QueuedAction action = ActionFeed[0];
            ActionFeed.RemoveAt(0);

            CurrentAction            = action.Action;
            Direction                = action.Direction;
            Model.transform.rotation = ClientFunctions.GetRotation(Direction);

            switch (CurrentAction)
            {
            case MirAction.Walking:
            case MirAction.Running:
                int steps = 1;
                if (CurrentAction == MirAction.Running)
                {
                    steps = 2;
                }

                Vector3 targetpos = GameManager.CurrentScene.Cells[(int)action.Location.x, (int)action.Location.y].position;
                TargetPosition = targetpos;

                if (this != GameManager.User.Player)
                {
                    Vector2 back = ClientFunctions.Back(action.Location, Direction, steps);
                    gameObject.transform.position = GameManager.CurrentScene.Cells[(int)back.x, (int)back.y].position;
                }

                GameManager.CurrentScene.Cells[(int)CurrentLocation.x, (int)CurrentLocation.y].RemoveObject(this);
                GameManager.CurrentScene.Cells[(int)action.Location.x, (int)action.Location.y].AddObject(this);

                StartPosition  = gameObject.transform.position;
                TargetDistance = Vector3.Distance(transform.position, targetpos);
                IsMoving       = true;
                break;
            }

            CurrentLocation = action.Location;

            if (this == GameManager.User.Player)
            {
                switch (CurrentAction)
                {
                case MirAction.Standing:
                    Network.Enqueue(new C.Turn {
                        Direction = action.Direction
                    });
                    GameManager.NextAction  = Time.time + 2.5f;
                    GameManager.InputDelay  = Time.time + 0.5f;
                    GameManager.User.CanRun = false;
                    break;

                case MirAction.Walking:
                    Network.Enqueue(new C.Walk {
                        Direction = action.Direction
                    });
                    GameManager.NextAction       = Time.time + 2.5f;
                    GameManager.InputDelay       = Time.time + 0.5f;
                    GameManager.User.LastRunTime = Time.time;
                    GameManager.User.CanRun      = true;
                    break;

                case MirAction.Running:
                    Network.Enqueue(new C.Run {
                        Direction = action.Direction
                    });
                    GameManager.NextAction       = Time.time + 2.5f;
                    GameManager.InputDelay       = Time.time + 0.5f;
                    GameManager.User.LastRunTime = Time.time;
                    break;

                case MirAction.Attack:
                    Network.Enqueue(new C.Attack {
                        Direction = Direction, Spell = Spell.None
                    });
                    GameManager.NextAction = Time.time + 2.5f;
                    break;
                }
            }

            switch (CurrentAction)
            {
            case MirAction.Attack:
                GetComponentInChildren <Animator>().Play("Attack", -1, normalizedTime: 0f);
                break;
            }
        }
        GetComponentInChildren <Animator>()?.SetInteger("CurrentAction", (int)CurrentAction);
    }
Ejemplo n.º 25
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Return))
        {
            if (ChatBar.gameObject.activeSelf)
            {
                if (ChatBar.text.Length > 0)
                {
                    Network.Enqueue(new C.Chat()
                    {
                        Message = ChatBar.text
                    });
                }
                ChatBar.text = string.Empty;
                ChatBar.gameObject.SetActive(false);
            }
            else
            {
                ChatBar.gameObject.SetActive(true);
                ChatBar.Select();
            }
        }

        if (SelectedItemImage.gameObject.activeSelf)
        {
            SelectedItemImage.transform.position = Input.mousePosition;
            SelectedItemImage.transform.SetAsLastSibling();
        }

        MouseObject = GetMouseObject();

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (Time.time > PickUpTime)
            {
                PickUpTime = Time.time + 0.2f;
                Network.Enqueue(new C.PickUp());
            }
        }

        if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
        {
            if (Input.GetMouseButton(0))
            {
                if (!eventSystem.IsPointerOverGameObject() && CanAttack())
                {
                    GameManager.InputDelay = Time.time + 0.5f;
                    NextHitTime            = Time.time + 1.6f;
                    QueuedAction           = new QueuedAction {
                        Action = MirAction.Attack, Direction = GameManager.MouseUpdate(), Location = User.Player.CurrentLocation
                    };
                }
                return;
            }
            else if (TargetObject != null && !(TargetObject is MonsterObject) && !TargetObject.Dead && TargetObject.gameObject.activeSelf && CanAttack())
            {
                Point self = new Point((int)User.Player.CurrentLocation.x, (int)User.Player.CurrentLocation.y);
                Point targ = new Point((int)TargetObject.CurrentLocation.x, (int)TargetObject.CurrentLocation.y);
                if (Functions.InRange(self, targ, 1))
                {
                    NextHitTime = Time.time + 1.6f;
                    MirDirection direction = Functions.DirectionFromPoint(self, targ);
                    QueuedAction = new QueuedAction {
                        Action = MirAction.Attack, Direction = direction, Location = User.Player.CurrentLocation
                    };
                    return;
                }

                MirDirection targetdirection = Functions.DirectionFromPoint(self, targ);

                if (!CanWalk(targetdirection))
                {
                    return;
                }

                QueuedAction = new QueuedAction {
                    Action = MirAction.Walking, Direction = targetdirection, Location = ClientFunctions.VectorMove(User.Player.CurrentLocation, targetdirection, 1)
                };
            }
        }

        if (Input.GetMouseButton(0) && !eventSystem.IsPointerOverGameObject())
        {
            GameManager.User.CanRun = false;

            if (SelectedCell != null)
            {
                SelectedItemImage.gameObject.SetActive(false);

                MessageBox.Show($"Drop {SelectedCell.Item.Name}?", true, true);
                MessageBox.OK += () =>
                {
                    Network.Enqueue(new C.DropItem {
                        UniqueID = SelectedCell.Item.UniqueID, Count = 1
                    });
                    SelectedCell.Locked = true;
                    SelectedCell        = null;
                };
                MessageBox.Cancel += () =>
                {
                    SelectedCell = null;
                };
                return;
            }

            if (MouseObject != null)
            {
                switch (MouseObject.gameObject.layer)
                {
                case 9:     //Monster
                    MonsterObject monster = (MonsterObject)MouseObject;
                    if (monster.Dead)
                    {
                        break;
                    }
                    TargetObject = monster;
                    return;
                }
            }

            TargetObject = null;
            GameManager.CheckMouseInput();
        }
        else if (Input.GetMouseButton(1) && !eventSystem.IsPointerOverGameObject())
        {
            GameManager.CheckMouseInput();
        }
        else
        {
            GameManager.User.CanRun = false;
            if (TargetObject != null && TargetObject is MonsterObject && !TargetObject.Dead && TargetObject.gameObject.activeSelf && CanAttack())
            {
                Point self = new Point((int)User.Player.CurrentLocation.x, (int)User.Player.CurrentLocation.y);
                Point targ = new Point((int)TargetObject.CurrentLocation.x, (int)TargetObject.CurrentLocation.y);
                if (Functions.InRange(self, targ, 1))
                {
                    NextHitTime = Time.time + 1.6f;
                    MirDirection direction = Functions.DirectionFromPoint(self, targ);
                    QueuedAction = new QueuedAction {
                        Action = MirAction.Attack, Direction = direction, Location = User.Player.CurrentLocation
                    };
                    return;
                }

                MirDirection targetdirection = Functions.DirectionFromPoint(self, targ);

                if (!CanWalk(targetdirection))
                {
                    return;
                }

                QueuedAction = new QueuedAction {
                    Action = MirAction.Walking, Direction = targetdirection, Location = ClientFunctions.VectorMove(User.Player.CurrentLocation, targetdirection, 1)
                };
            }
        }
    }
Ejemplo n.º 26
0
    void Update()
    {
        Network.Process();

        ProcessScene();
    }
Ejemplo n.º 27
0
    void SetAction()
    {
        if (ActionFeed.Count == 0)
        {
            CurrentAction = MirAction.Standing;
            if (this == GameManager.User.Player)
            {
                GameManager.User.WalkStep = 0;
            }
        }
        else
        {
            if (Time.time < GameManager.NextAction)
            {
                return;
            }

            QueuedAction action = ActionFeed[0];
            ActionFeed.RemoveAt(0);

            CurrentAction = action.Action;
            Direction     = action.Direction;

            switch (CurrentAction)
            {
            case MirAction.Walking:
            case MirAction.Running:
                int steps = 1;
                if (CurrentAction == MirAction.Running)
                {
                    steps = 2;
                }

                Vector3 targetpos = GameManager.CurrentScene.Cells[(int)action.Location.x, (int)action.Location.y].position;
                Model.transform.rotation = ClientFunctions.GetRotation(Direction);
                TargetPosition           = targetpos;

                if (this != GameManager.User.Player)
                {
                    Vector2 back = ClientFunctions.Back(action.Location, Direction, steps);
                    gameObject.transform.position = GameManager.CurrentScene.Cells[(int)back.x, (int)back.y].position;
                }

                StartPosition  = gameObject.transform.position;
                TargetDistance = Vector3.Distance(transform.position, targetpos);
                IsMoving       = true;
                break;
            }

            CurrentLocation = action.Location;

            if (this == GameManager.User.Player)
            {
                switch (CurrentAction)
                {
                case MirAction.Walking:
                    Network.Enqueue(new C.Walk {
                        Direction = action.Direction
                    });
                    GameManager.NextAction = Time.time + 2.5f;
                    GameManager.InputDelay = Time.time + 0.5f;
                    break;

                case MirAction.Running:
                    Network.Enqueue(new C.Run {
                        Direction = action.Direction
                    });
                    GameManager.NextAction = Time.time + 2.5f;
                    GameManager.InputDelay = Time.time + 0.5f;
                    break;
                }
            }
        }
        GetComponentInChildren <Animator>().SetInteger("CurrentAction", (int)CurrentAction);
    }