Пример #1
0
        public UnitEntity(int id, String name, GameClassConfig classcfg, int modelHair, int modelFace, int maxHP, int maxSP, GameMain game, ContentManager content, GraphicsDeviceManager graphics, SpriteBatch spriteBatch, SpriteFont charNameFont, SpriteFont charDamageFont, Texture2D whiteRect, GameModelBank modelBank, GameItemBank itemBank, AudioSystem audioSystem, ParticlePreset particleManager)
        {
            this.id             = id;
            name                = name.Replace("'58'", ":");
            name                = name.Replace("'59'", ";");
            name                = name.Replace("'32'", " ");
            name                = name.Replace("'39'", "'");
            this.name           = name;
            this.game           = game;
            this.content        = content;
            this.graphics       = graphics;
            this.spriteBatch    = spriteBatch;
            this.classcfg       = classcfg;
            this.modelBank      = modelBank;
            this.itemBank       = itemBank;
            this.charNameFont   = charNameFont;
            this.charDamageFont = charDamageFont;
            this.whiteRect      = whiteRect;
            short modelKey = classcfg.modelID;

            model = new GameModelNode(content, modelBank);
            model.Load(modelKey);
            model.Rotation = modelBank.getModelRotation(modelKey);
            model.Position = modelBank.getModelPosition(modelKey);
            model.Scale    = modelBank.getModelScale(modelKey);
            model.playClip((short)state, true);
            this.maxHP           = this.curHP = maxHP;
            this.maxSP           = this.curSP = maxSP;
            this.audioEmitter    = new AudioEmitter();
            this.audioSystem     = audioSystem;
            this.particleManager = particleManager;
            for (int i = 0; i < listDamageSize; ++i)
            {
                listDamageValue[i] = -1;
                listDamageTime[i]  = -1;
            }
        }
Пример #2
0
        public void load()
        {
            char_class.Items.Clear();
            classIdPair.Clear();
            // Load character data
            createButton.Enabled = false;
            backButton.Enabled   = false;
            game.messageDialog.setTitle("");
            game.messageDialog.setMessage("Please wait...");
            game.messageDialog.Visible            = true;
            game.messageDialog.CloseButtonVisible = false;
            String responseMsg = "";

            try
            {
                // Try connect to server
                //if (!network.isConnected())
                //    network.Connect("127.0.0.1", 5000);
                // Send login message
                network.Send("CHARCREATEABLE:" + LoggedUserID + ";"); // Get character from index
                // Receive message
                while (responseMsg.Length <= 0)
                {
                    responseMsg = network.Receive();
                }
            }
            catch (Exception e)
            {
                // Has any error come here
                Debug.WriteLine(e.ToString());
                game.messageDialog.setTitle("ERROR!!");
                game.messageDialog.setMessage("Can't connect to server.");
                game.messageDialog.Visible            = true;
                game.messageDialog.CloseButtonVisible = true;
                state = GameState.none;
            }
            // Split message from end of line
            String[] line = responseMsg.Split(';');
            for (int i = 0; i < line.Length; ++i)
            {
                // If has message
                // CHARCREATEAVAILABLE:{ID1} {ID2} {ID3} ... {ID4};
                String[] msg = line[i].Split(':');
                if (msg[0].Equals("CHARCREATEABLE") && msg.Length == 2)
                {
                    // Split message value
                    List <String> value = new List <String>(msg[1].Split(' '));
                    for (int j = 0; j < value.Count; ++j)
                    {
                        short           classid = Convert.ToInt16(value[j]);
                        GameClassConfig cfg     = null;
                        if (classConfigs.TryGetValue(classid, out cfg))
                        {
                            char_class.Items.Add(cfg.name);
                            classIdPair.Add(classid);
                        }
                    }
                }
            }
            char_class.ItemIndex = 0;
            game.hideMessageDialog();
            createButton.Enabled = true;
            backButton.Enabled   = true;
        }