예제 #1
0
        public void Update(GameTime gameTime, ReadManager rm)
        {
            if (enums.gState == GameState.Game)
            {
                light.Position = new Vector2(870f, 345f);
                light.Scale    = new Vector2(700f);
            }
            else if (enums.gState == GameState.Combat)
            {
                light.Position = new Vector2(950f, 345f);
                light.Scale    = new Vector2(2300f);
            }
            else if (enums.gState == GameState.Menu)
            {
                light.Position = new Vector2(900f, 345f);
                light.Scale    = new Vector2(700f);
            }
            penumbra.AmbientColor = Color.Black;

            foreach (Tile t in rm.tileList)
            {
                hull.Position = t.position;
            }

            hull.Rotation = MathHelper.WrapAngle(-(float)gameTime.TotalGameTime.TotalSeconds);
        }
예제 #2
0
        public void test_AlphabeticalDictionary()
        {
            //arrange
            Stream                   stream       = new FileStream("TestFile2.txt", FileMode.Open);
            CharacterReader          cr           = new CharacterReader(stream);
            Dictionary <string, int> myDictionary = new Dictionary <string, int>();

            myDictionary.Add("a", 1);
            myDictionary.Add("is", 1);
            myDictionary.Add("test", 2);
            myDictionary.Add("This", 1);


            //act
            ReadManager rm = new ReadManager(cr);
            Dictionary <string, int> myActualDictionary = new Dictionary <string, int>();

            foreach (KeyValuePair <string, int> word in myDictionary.OrderBy(key => key.Key))
            {
                myActualDictionary.Add(word.Key, word.Value);
            }

            //assert
            CollectionAssert.AreEqual(myDictionary, myActualDictionary);
        }
예제 #3
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            string table = "PlayerInfo";

            string[] cols = new string[] { "password", "number" };
            string[] typ  = new string[] { "TEXT", "INTEGER" };
            //SqlManager.instance.CreateTable("student", cols, typ);
            //string[] op = new string[] { "=","<" };
            //string[] values = new string[] { "123456","10" };
            //SqlManager.instance.UpdateData(table, cols, values, "username", "=", "sdsd");
            //string[] field = new string[] {"username"};
            //SqliteDataReader reader = SqlManager.instance.SelectWhere(table, cols, op, values,field);

            //SqliteDataReader reader = SqlManager.instance.SelectFromTable(table,field);
            SqliteDataReader reader = SqlManager.instance.SelectFromTable(table);
            List <string>    list   = new List <string>();
            list = SqlManager.instance.GetTableFieldInfo(table);
            foreach (var item in list)
            {
                print(item);
            }
            //string[] val = new string[] { "gpppp"};
            //string[] col = new string[] { "asda" };

            //SqlManager.instance.InsertInto(table, val,col);

            //string t1 = "Test";
            //string[] v1 = new string[] { "1" };
            //string[] c1 = new string[] { "sss" };
            //string[] o1 = new string[] { "="};
            //SqlManager.instance.Delete(t1, c1, o1, v1);
            //SqlManager.instance.DeleteAllTable(t1);
            Dictionary <string, string> dic = new Dictionary <string, string>();
            while (reader.Read())
            {
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    dic.Add(list[i], reader.GetValue(i).ToString());
                }
            }
            SqlManager.instance.CloseDB();
            ReadManager.TypeChange <PlayerInfo>(PlayerInfo.Instance, dic);

            Debug.Log(PlayerInfo.Instance.level);
            Debug.Log(PlayerInfo.Instance.Crit);
            //string p = "csvRoleInfo.csv";
            //List<csvRoleInitInfo> l = new List<csvRoleInitInfo>();
            //l = ReadManager.ReaderCSV<csvRoleInitInfo>(p);
            //for (int i = 0; i < l.Count; i++)
            //{
            //    print(l[i].name + "  " + l[i].description);
            //}
        }
    }
예제 #4
0
        public override async Task <VTQ[]> ReadDataItems(string group, IList <ReadRequest> items, Duration?timeout)
        {
            bool connected = await TryConnect();

            if (!connected || connection == null)
            {
                return(GetBadVTQs(items));
            }

            var readHelper = new ReadManager <ReadValueId, Workstation.ServiceModel.Ua.DataValue>(items, request => {
                NodeId node = mapId2Info[request.ID].Node ?? NodeId.Null;
                return(new ReadValueId {
                    AttributeId = AttributeIds.Value, NodeId = node
                });
            });

            ReadValueId[] dataItemsToRead = readHelper.GetRefs();

            try {
                VTQ[] result;

                if (dataItemsToRead.Length > 0)
                {
                    var readRequest = new Workstation.ServiceModel.Ua.ReadRequest {
                        NodesToRead        = dataItemsToRead,
                        TimestampsToReturn = TimestampsToReturn.Source,
                    };

                    ReadResponse readResponse = await connection.ReadAsync(readRequest);

                    readHelper.SetAllResults(readResponse.Results, (vv, request) => MakeVTQ(vv, request.LastValue, request.ID));
                    result = readHelper.values;
                }
                else
                {
                    result = readHelper.values;
                }

                if (readExceptionWarning)
                {
                    readExceptionWarning = false;
                    ReturnToNormal("UAReadExcept", "ReadDataItems successful again");
                }

                return(result);
            }
            catch (Exception exp) {
                Exception e = exp.GetBaseException() ?? exp;
                readExceptionWarning = true;
                LogWarn("UAReadExcept", $"Read exception: {e.Message}", details: e.ToString());
                Task ignored = CloseChannel();
                return(GetBadVTQs(items));
            }
        }
예제 #5
0
 public DynamicSpikeTrap(Texture2D texture, Vector2 position, bool isWall, Rectangle hitbox, Texture2D fakeHitbox, ReadManager rm) : base(texture, position, isWall, hitbox, fakeHitbox)
 {
     textureData = new Color[fakeHitbox.Width * fakeHitbox.Height];
     fakeHitbox.GetData(textureData);
     frameTimer    = 500;
     frameInterval = 500;
     rotation      = 0;
     frame         = 6;
     Damage        = 0;
     this.rm       = rm;
     this.
     sourceRectangle = new Rectangle(0, 0, 32, 32);
 }
예제 #6
0
        public override async Task <VTQ[]> ReadDataItems(string group, IList <ReadRequest> items, Duration?timeout)
        {
            if (!await TryConnect() || connection == null)
            {
                return(GetBadVTQs(items));
            }

            var readHelper = new ReadManager <VariableRef, VariableValue>(items, readRequest => mapId2Info[readRequest.ID].VarRef);
            List <VariableRef> dataItemsToRead = readHelper.GetRefsList();

            try {
                List <VariableValue> readResponse = await connection.ReadVariablesSyncIgnoreMissing(dataItemsToRead);

                if (readResponse.Count == dataItemsToRead.Count)
                {
                    readHelper.SetAllResults(readResponse, (vv, request) => vv.Value);
                    return(readHelper.values);
                }
                else
                {
                    var badDataItems = new List <DataItem>();
                    for (int i = 0; i < dataItemsToRead.Count; ++i)
                    {
                        VariableRef v = dataItemsToRead[i];
                        try {
                            VariableValue value = readResponse.First(rr => rr.Variable == v);
                            readHelper.SetSingleResult(i, value.Value);
                        }
                        catch (Exception) { // not found
                            ReadRequest req = readHelper.GetReadRequest(i);
                            readHelper.SetSingleResult(i, VTQ.Make(req.LastValue.V, Timestamp.Now, Quality.Bad));
                            DataItem dataItem = mapId2Info[req.ID].Item;
                            badDataItems.Add(dataItem);
                        }
                    }

                    string[] dataItemNamesWithAddresss = badDataItems.Select(di => di.Name + ": " + di.Address).ToArray();
                    string   details = string.Join("; ", dataItemNamesWithAddresss);
                    string   msg     = badDataItems.Count == 1 ? $"Invalid address for data item '{badDataItems[0].Name}': {badDataItems[0].Address}" : $"Invalid address for {badDataItems.Count} data items";
                    LogError("Invalid_Addr", msg, badDataItems.Select(di => di.ID).ToArray(), details);

                    return(readHelper.values);
                }
            }
            catch (Exception exp) {
                Exception e = exp.GetBaseException() ?? exp;
                LogWarn("ReadExcept", $"Read exception: {e.Message}", details: e.ToString());
                Task ignored = CloseConnection();
                return(GetBadVTQs(items));
            }
        }
예제 #7
0
        public Devil(Texture2D texture, Vector2 position, bool isWall, Rectangle hitbox, ReadManager rm) : base(texture, position, isWall, hitbox, rm)
        {
            textureData = new Color[texture.Width * texture.Height];
            texture.GetData(textureData);
            this.rm         = rm;
            CurrentPosition = position;

            // Stats
            Health   = 200;
            Mana     = 100;
            Damage   = rnd.Next(15, 35);
            Defense  = 10;
            ExpGiven = 400;
        }
예제 #8
0
        public InventoryManager(ReadManager rm)
        {
            this.rm       = rm;
            equipmentFull = false;
            inventoryFull = false;

            // Items
            runeOfEarth = new Item("Rune of Earth", "A rune molded from the deepest part of the earth itself. Grants the user 10 strength", 0, 0, 0, 0, 10);
            runeOfFire  = new Item("Rune of Fire", "A rune molded from the fire of an active volcano. Grants the user 10 intelligence", 0, 0, 10, 0, 0);
            runeOfWind  = new Item("Rune of Wind", "A rune that drifts in the wind, with zero resistance. Grants the user 10 agility", 0, 0, 0, 10, 0);
            itemsInWorld.Add(runeOfEarth);
            itemsInWorld.Add(runeOfFire);
            itemsInWorld.Add(runeOfWind);
        }
예제 #9
0
 /**
  * Read from the server and write to the console
  */
 private void ThreadedReadRun()
 {
     while (IsAlive())
     {
         try
         {
             ReadManager.Run(Stream);
         }
         catch (Exception)
         {
             return;
         }
     }
 }
예제 #10
0
 /**
  * Initialize method which will create the socket
  */
 private void Initialize(string ip, int port)
 {
     IsInitialized = false;
     try
     {
         ReadManager.Initialize(ReadHandlers);
         WriteManager.Initialize(WriteHandlers);
         InputManager.Initialize(InputInfos);
         Socket.Connect(ip, port);
         Stream        = Socket.GetStream();
         IsInitialized = true;
     }
     catch (Exception e)
     {
         Console.Out.WriteLineAsync(e.ToString());
     }
 }
예제 #11
0
        public void test_Dictionary()
        {
            //arrange
            Stream                   stream       = new FileStream("TestFile.txt", FileMode.Open);
            CharacterReader          cr           = new CharacterReader(stream);
            Dictionary <string, int> myDictionary = new Dictionary <string, int>();

            myDictionary.Add("This", 1);
            myDictionary.Add("is", 1);
            myDictionary.Add("a", 1);
            myDictionary.Add("test", 1);

            //act
            ReadManager rm = new ReadManager(cr);


            //assert
            CollectionAssert.AreEqual(myDictionary, rm.MyDictionary);
        }
예제 #12
0
        /**
         * Initiliaze listener
         */
        private bool Initialize(int port = DefaultServerPort)
        {
            IsInitialized = false;
            try
            {
                ReadManager.Initialize(ReadHandlers);
                WriteManager.Initialize(WriteHandlers);

                Listener = new TcpListener(IPAddress.Any, port);

                ClientList = new Dictionary <int, Client>();
                LobbyList  = new List <Lobby>();

                Listener.Start();
                IsInitialized = true;
                return(true);
            }
            catch (Exception e)
            {
                Console.Out.WriteLineAsync(e.ToString());
                return(false);
            }
        }
예제 #13
0
 public Mage(Texture2D texture, Vector2 position, bool isWall, Rectangle hitbox, ReadManager rm, ContentManager content) : base(texture, position, isWall, hitbox, rm, content)
 {
     // Booleans
     doThisOnce       = true;
     ManaCostOnce     = true;
     healingRecharged = true;
     drawParticles    = false;
     loadParticles    = false;
     // ints and floats
     roundDuration  = 3;
     roundEffectEnd = 100;
     // Extra
     this.rm = rm;
     // Stats
     maxHealth    = 80;
     health       = 80;
     maxMana      = 120;
     mana         = 120;
     strength     = 5;
     intelligence = 15;
     agility      = 10;
     spellDamage  = 0;
     // Spells
     spell1Name = "Wizard's blessing";
     spell2Name = "Flame Rush";
     spell3Name = "Fireball";
     spell4Name = "Ice Block";
     spell1Desc = "Pray to the God of Wisdom and Magic, Hecate. Allowing you to regenerate 20 mana.";
     spell2Desc = "Catch your opponent off guard with a quick attack, doing 15 + (20 * spell rank) damage.";
     spell3Desc = "hej";
     spell4Desc = "Encase yourself in solid ice, blocking any and all enemy attacks for one turn";
     manaCost1  = 15;
     manaCost2  = 30;
     manaCost3  = 20;
     manaCost4  = 80;
 }
예제 #14
0
 public RestorationBlock(Texture2D texture, Vector2 position, bool isWall, Rectangle hitBox, ReadManager rm) : base(texture, position, isWall, hitBox)
 {
     this.rm  = rm;
     Health   = 10;
     coolDown = 0;
 }
예제 #15
0
 /**
  * HandleRequest
  */
 public void HandleRequest(NetworkStream networkStream, int clientId)
 {
     ReadManager.Run(networkStream, clientId);
 }
예제 #16
0
 public InventoryManager(ReadManager rm)
 {
     this.rm = rm;
 }