Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var exp = new Experiment();

            Widget w = exp.GetEntity();
            Doodad d = exp.GetEntity();
        }
Exemplo n.º 2
0
 public override void Enable()
 {
     base.Enable();
     _mouseFollow = new Doodad(Controller.Level);
     _mouseFollow.Models.Add(ModelFactory.CreatePlayer());
     _mouseFollow.IsPortalable = true;
 }
Exemplo n.º 3
0
 public Doodad GetDoodad(Biome biome)
 {
     if (biome == borealBiome)
     {
         if (borealDoodad == null)
         {
             borealDoodad = new Doodad(borealColor, borealDoodadSpec, material);
         }
         return(borealDoodad);
     }
     else if (biome == mountainBorealBiome)
     {
         if (mountainBorealDoodad == null)
         {
             mountainBorealDoodad = new Doodad(mountainBorealColor, mountainBorealDoodadSpec, material);
         }
         return(mountainBorealDoodad);
     }
     else if (biome == mountainForestBiome)
     {
         if (mountainForestDoodad == null)
         {
             mountainForestDoodad = new Doodad(mountainForestColor, mountainForestDoodadSpec, material);
         }
         return(mountainForestDoodad);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 4
0
        public override void Use(Unit caster, Doodad owner, uint skillId)
        {
            _log.Debug("DoodadFuncEnterSysInstance, ZoneId: {0}", ZoneId);
            if (caster is Character character)
            {
                character.DisabledSetPosition = true;
                var zone  = ZoneManager.Instance.GetZoneById(ZoneId);
                var world = WorldManager.Instance.GetWorldByZone(zone.ZoneKey);

                if (world.SpawnPosition != null)
                {
                    character.SendPacket(
                        new SCLoadInstancePacket(
                            world.Id,
                            world.SpawnPosition.ZoneId,
                            world.SpawnPosition.X,
                            world.SpawnPosition.Y,
                            world.SpawnPosition.Z,
                            0,
                            0,
                            0
                            )
                        );

                    character.InstanceId       = world.Id; // TODO all instances are sys now
                    character.WorldPosition    = character.Position.Clone();
                    character.Position         = world.SpawnPosition.Clone();
                    character.Position.WorldId = world.Id;
                }
                else
                {
                    _log.Warn("World #.{0}, not have default spawn position.", world.Id);
                }
            }
        }
Exemplo n.º 5
0
        private void Update()
        {
            elapsed += Time.deltaTime;
            if (elapsed > target)
            {
                int2 spawn   = new int2(Mathf.Abs(Mathf.RoundToInt(SpawnerPosition.x)), Mathf.Abs(Mathf.RoundToInt(SpawnerPosition.z)));
                var  mapsize = GameSettings.MapSize;

                int2 targetPos = new int2(Random.Range(-mapsize.x, mapsize.x), Random.Range(0, mapsize.y));

                if (Mathf.Abs(spawn.x - Mathf.Abs(targetPos.x)) < 5)
                {
                    return;
                }
                if (Mathf.Abs(spawn.y - Mathf.Abs(targetPos.y)) < 5)
                {
                    return;
                }
                if (Doodad.GetDoodadAtLocation(targetPos)?.Find <Obstacle>())
                {
                    return;
                }
                var parts = ShipPartPrefabs.Instance.OtherParts;
                Instantiate(parts[Random.Range(0, parts.Count)], new Vector3(targetPos.x, 10, targetPos.y), Quaternion.identity);

                elapsed = 0;
                target  = Random.Range(2f, 7f);
            }
        }
        public override void Use(Unit caster, Doodad owner, uint skillId)
        {
            _log.Debug("DoodadFuncExitIndun, ReturnPointId: {0}", ReturnPointId);

            if (caster is Character character)
            {
                if (ReturnPointId == 0 && character.WorldPosition != null)
                {
                    character.DisabledSetPosition = true;

                    character.SendPacket(
                        new SCLoadInstancePacket(
                            1,
                            character.WorldPosition.ZoneId,
                            character.WorldPosition.X,
                            character.WorldPosition.Y,
                            character.WorldPosition.Z,
                            0,
                            0,
                            0
                            )
                        );

                    character.InstanceId    = 1; // TODO ....
                    character.Position      = character.WorldPosition.Clone();
                    character.WorldPosition = null;
                }
                else
                {
                    // TODO in db not have a entries, but we can change this xD
                    _log.Warn("DoodadFuncExitIndun, Not have return point!");
                }
            }
        }
Exemplo n.º 7
0
    public GameObject instantiateA(Doodad doodad, Vector3 pos, float scale)
    {
        GameObject doodadClone = doodad.instantiateAt(pos, scale);

        doodadClone.transform.parent = transform;

        return(doodadClone);
    }
Exemplo n.º 8
0
 public override void Use(Unit caster, Doodad owner, uint skillId)
 {
     _log.Debug("DoodadFuncAttachment");
     if (caster is Character character)
     {
         character.Bonding = new BondDoodad(owner, AttachPointId, BondKindId, Space, 0);
         character.BroadcastPacket(new SCBondDoodadPacket(caster.ObjId, character.Bonding), true);
     }
 }
Exemplo n.º 9
0
        public virtual void AddDoodad(Doodad doodad)
        {
            Vector3 localPosition = doodad.transform.localPosition;
            Vector3 localScale    = doodad.transform.localScale;

            doodad.transform.SetParent(this.transform);
            doodad.transform.localPosition = localPosition;
            doodad.transform.localScale    = localScale;
        }
Exemplo n.º 10
0
        public void RequestCell(StreamConnection connection, uint instanceId, int x, int y)
        {
            var doodads   = WorldManager.Instance.GetInCell <Doodad>(instanceId, x, y).ToArray(); // TODO active worldId from character
            var requestId = connection.GetNextRequestId(doodads);
            var count     = Math.Min(doodads.Length, 30);
            var res       = new Doodad[count];

            Array.Copy(doodads, 0, res, 0, count);
            connection.SendPacket(new TCDoodadStreamPacket(requestId, count, res));
        }
 public override void Use(Unit caster, Doodad owner, uint skillId)
 {
     _log.Debug("DoodadFuncGrowth");
     if (Delay > 0)
     {
         owner.GrowthTime = DateTime.Now.AddMilliseconds(Delay);
         owner.FuncTask   = new DoodadFuncGrowthTask(caster, owner, skillId, NextPhase);
         TaskManager.Instance.Schedule(owner.FuncTask, TimeSpan.FromMilliseconds(Delay));
     }
 }
 public override void Use(Unit caster, Doodad owner, uint skillId)
 {
     _log.Debug("DoodadFuncFinal");
     if (After > 0)
     {
         owner.GrowthTime = DateTime.Now.AddMilliseconds(After); // TODO ... need here?
         owner.FuncTask   = new DoodadFuncFinalTask(caster, owner, skillId, Respawn);
         TaskManager.Instance.Schedule(owner.FuncTask, TimeSpan.FromMilliseconds(After));
     }
 }
Exemplo n.º 13
0
 private void OnCollisionEnter(Collision other)
 {
     if (other.gameObject.TryFind(out Doodad doodad))
     {
         DoodadCollision = doodad;
     }
     if (other.gameObject.TryFind(out Player player))
     {
         PlayerCollision = player;
     }
 }
Exemplo n.º 14
0
        public override void AddDoodad(Doodad doodad)
        {
            base.AddDoodad(doodad);

            if (doodad.GetType() == typeof(Boulder))
            {
                //boulder pushed into water, so replace water with dirty water
                this.Replace(dirtyWaterTile);
                Destroy(doodad.gameObject);
            }
        }
Exemplo n.º 15
0
        public override void WireScriptsAndValidate()
        {
            Expect.IsNotNullOrEmpty(this.jsonId, "JsonId must be explicitly set: " + this.ToString());
            this.DomId = this.JsonId;
            DatabaseAgent agent = GetAgent();

            this.tree = Doodad.GetDoodad(this.JsonId, agent);

            this.OnFolderOptionClicked = "JSUI." + this.JsonId + ".folderAction"; // in datatree.util.js
            this.OnFileOptionClicked   = "JSUI." + this.JsonId + ".fileAction";
            base.WireScriptsAndValidate();
        }
Exemplo n.º 16
0
        public static void TestTemplateCtorDoodad()
        {
            var c1 = new Doodad();

            Assert.True(c1 is Doodad);
            Assert.AreDeepEqual(3, c1.Data);

            var c2 = new Doodad(1);

            Assert.True(c2 is Doodad);
            Assert.AreDeepEqual(4, c2.Data);
        }
Exemplo n.º 17
0
        public Chunk_MODD(WMOFile file) : base(file, "MODD", Magic)
        {
            int doodadCount = (int)ChunkSize / 40;

            doodads = new Doodad[doodadCount];

            for (int i = 0; i < doodadCount; i++)
            {
                doodads[i] = Doodad.Read(file);
            }

            LogWrite("Loaded " + doodadCount + " doodads.");
        }
Exemplo n.º 18
0
        public Doodad PlaceDoodad(int pixelX, int pixelY, string filename)
        {
            UnitList list = null;

            if (!Units.TryGetValue(filename, out list))
            {
                list            = new UnitList(filename);
                Units[filename] = list;
            }
            var ret = new Doodad(pixelX, pixelY);

            list.Add(ret);
            return(ret);
        }
Exemplo n.º 19
0
 public void ResetDoodads()
 {
     if (borealDoodad != null)
     {
         borealDoodad = null;
     }
     if (mountainBorealDoodad != null)
     {
         mountainBorealDoodad = null;
     }
     if (mountainForestDoodad != null)
     {
         mountainForestDoodad = null;
     }
 }
Exemplo n.º 20
0
 //Doodad may have their own struct later on and moved into a global
 private void PlaceDoodad(TileType[,] area, Doodad fill, int x_coord, int y_coord, int size_x, int size_y)
 {
     /*
      * if (area.GetLength (0) > x_coord + size_x - 1 && area.GetLength (1) > y_coord + size_y - 1) {
      *      switch(fill){
      *      case Doodad.Gate:
      *              area[x_coord, y_coord] = TileType.NorthGate1;
      *              area[x_coord + 1, y_coord] = TileType.NorthGate2;
      *              break;
      *      default:
      *              break;
      *      }
      * }
      */
 }
Exemplo n.º 21
0
        public override void Use(Unit caster, Doodad owner, uint skillId)
        {
            _log.Debug("DoodadFuncTimer : NextPhase {0}, SkillId {1}", NextPhase, skillId);

            //This is a temporary fix. We need to find how to properly call the next function.
            // var nextFunc = DoodadManager.Instance.GetFunc(owner.FuncGroupId, skillId);
            // if (nextFunc != null) nextFunc.Use(caster, owner, skillId);

            if (Delay > 0)
            {
                owner.GrowthTime = DateTime.Now.AddMilliseconds(Delay); // TODO ... need here?
                owner.FuncTask   = new DoodadFuncTimerTask(caster, owner, skillId, NextPhase);
                TaskManager.Instance.Schedule(owner.FuncTask, TimeSpan.FromMilliseconds(Delay));
            }
        }
Exemplo n.º 22
0
        public DataControl()
            : base()
        {
            string applicationName = LogManager.Current.ApplicationName;

            this.UserDatabase = UserDb.Current;
            this.UserDatabase.EnsureSchema <Doodad>();
            this.ApplicationDatabase = AppDb.Current;//new SQLiteAgent(@"Data Source=.\StateData\" + applicationName + ".db3;Version=3;");
            this.ApplicationDatabase.EnsureSchema <Doodad>();
            this.CrossSessionMode = CrossSessionMode.Application;
            JavascriptServer.RegisterProvider(this);
            this.DoodadInit = (d) =>
            {
                return(Doodad.GetDoodad(this.jsonId, GetAgent()));
            };
        }
Exemplo n.º 23
0
        public Doodad Create(uint bcId, uint id, Character character)
        {
            if (!_templates.ContainsKey(id))
            {
                return(null);
            }
            var template = _templates[id];
            var doodad   = new Doodad();

            doodad.ObjId       = bcId > 0 ? bcId : ObjectIdManager.Instance.GetNextId();
            doodad.TemplateId  = template.Id;
            doodad.Template    = template;
            doodad.OwnerBcId   = character?.ObjId ?? 0;
            doodad.OwnerId     = character?.Id ?? 0;
            doodad.FuncGroupId = doodad.GetGroupId(); // TODO look, using doodadFuncId
            return(doodad);
        }
Exemplo n.º 24
0
        protected virtual void Start()
        {
            board.Size = Random.Range(15, 35);

            land      = new Land(board, factory, Random.Range(0.025f, 0.75f));;
            doodad    = new Doodad(board, factory, Random.Range(0.05f, 0.2f));
            river     = new Track(board, factory, factory.RiverStraight, Random.Range(0.05f, 0.10f));
            road      = new Track(board, factory, factory.RoadStraight, Random.Range(0.075f, 0.15f));
            rectifier = new Rectifier(board, factory);
            float center = board.Size % 2 == 0 ? board.Size / 2 - 0.5f : board.Size / 2 + 0.0f;

            mainCamera.transform.position = new Vector3(center, center, -board.Size);
            land.Size = board.Size;
            text.text = statePrefix + "Generating Land";
            timeController.Reset();
            timeController.SetTime(0.01f);
        }
Exemplo n.º 25
0
 //Reserved a plot of land for example a larger tree or a building or a bandit camp
 private void FillWithTile(TileType[,] area, TileType scanTarget, Doodad fill, int acceptedClearance, int size_x, int size_y)
 {
     /*
      * int x_coord = 0;
      * int y_coord = 0;
      * int perimeter = 2 * size_x + 2 * size_y;
      * bool clearance = false;
      *
      * if(acceptedClearance <= perimeter){
      *      do{
      *              x_coord = (int)Random.Range (0, _tileData.GetLength(0) - size_x);
      *              y_coord = (int)Random.Range (0, _tileData.GetLength(1) - size_y);
      *              if(ScanEdge(area, scanTarget, size_x, size_y, x_coord, y_coord) >= acceptedClearance)
      *                      clearance = true;
      *      }while(!clearance);
      *      if(clearance){
      *              //Check
      *              PlaceDoodadHolder (area, size_x, size_y, x_coord, y_coord);
      *
      *              switch(fill){
      *              case Doodad.Dirt:
      *                      area[x_coord, y_coord] = TileType.DirtToGrassBL;
      *                      area[x_coord + size_x - 1, y_coord] = TileType.DirtToGrassBR;
      *                      area[x_coord, y_coord + size_y - 1] = TileType.DirtToGrassTL;
      *                      area[x_coord + size_x - 1, y_coord + size_y - 1] = TileType.DirtToGrassTR;
      *                      for (int y = y_coord + 1; y < y_coord + size_y - 1; y++){
      *                              area[x_coord, y] = TileType.DirtToGrassL;
      *                              area[x_coord + size_x - 1 , y] = TileType.DirtToGrassR;
      *                      }
      *                      for (int x = x_coord + 1; x < x_coord + size_x - 1; x++){
      *                              area[x, y_coord] = TileType.DirtToGrassB;
      *                              area[x, y_coord + size_y - 1] = TileType.DirtToGrassT;
      *                      }
      *                      for (int y = y_coord + 1; y < y_coord + size_y - 1; y++)
      *                              for (int x = x_coord +1; x < x_coord + size_x - 1; x++)
      *                                      area[x, y] = TileType.Dirt;
      *                      break;
      *              default:
      *                      break;
      *
      *              }
      *      }
      * }
      */
 }
Exemplo n.º 26
0
        public static Dm.Doodad ToDataModel(this Doodad model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new Dm.Doodad
            {
                Id = model.Id,
                WidgetId = model.WidgetId,
                Widget = model.Widget.ToDataModel(),
                Name = model.Name,
                Active = model.Active,
                Created = model.Created,
                Updated = model.Updated
            });
        }
Exemplo n.º 27
0
        public static HtmlGenericControl GetHtmlTreeFrom(Doodad tree, string jsonId)
        {
            HtmlGenericControl topLevelUL = new HtmlGenericControl("ul");

            topLevelUL.Attributes.Add("class", "filetree");
            topLevelUL.Style.Add("display", "none");
            topLevelUL.Attributes.Add("jsonid", jsonId);
            foreach (Node node in tree.Folders)
            {
                topLevelUL.Controls.Add(GetHtmlFolderNode(node, jsonId));
            }

            foreach (Node node in tree.Files)
            {
                topLevelUL.Controls.Add(GetHtmlFileNode(node));
            }

            return(topLevelUL);
        }
Exemplo n.º 28
0
    public Doodad getRandomDoodad()
    {
        Doodad generatedDoodad = null;

        foreach (Doodad script in scripts)
        {
            if (((generatedDoodad == null) ||
                 (script.rarity >= generatedDoodad.rarity)) &&
                (Random.Range(0, script.rarity * 4) == 0))
            {
                generatedDoodad = script;
            }
            if (script.force)
            {
                generatedDoodad = script;
            }
        }
        return(generatedDoodad);
    }
Exemplo n.º 29
0
        public void AddToCharacters(GameObject obj)
        {
            if (_objects == null)
            {
                return;
            }

            // показать игроку все обьекты в регионе
            if (obj is Character)
            {
                var character = (Character)obj;

                var units = GetList(new List <Unit>(), obj.ObjId);
                for (var i = 0; i < units.Count; i++)
                {
                    if (units[i] is House house)
                    {
                        house.AddVisibleObject(character);
                    }
                    else
                    {
                        character.SendPacket(new SCUnitStatePacket(units[i]));
                    }
                }

                var doodads = GetList(new List <Doodad>(), obj.ObjId).ToArray();
                for (var i = 0; i < doodads.Length; i += 30)
                {
                    var count = doodads.Length - i;
                    var temp  = new Doodad[count <= 30 ? count : 30];
                    Array.Copy(doodads, i, temp, 0, temp.Length);
                    character.SendPacket(new SCDoodadsCreatedPacket(temp));
                }

                // TODO ... others types...
            }

            // показать обьект всем игрокам в регионе
            foreach (var character in GetList(new List <Character>(), obj.ObjId))
            {
                obj.AddVisibleObject(character);
            }
        }
Exemplo n.º 30
0
        public void ContinueCell(StreamConnection connection, int requestId, int next)
        {
            var doodads = connection.GetRequest(requestId);

            if (doodads == null)
            {
                return;
            }
            if (next >= doodads.Length)
            {
                connection.RemoveRequest(requestId);
            }
            var count = Math.Min(doodads.Length - next, 30);
            var res   = new Doodad[count];

            Array.Copy(doodads, next > 0 ? next - 1 : 0, res, 0, count);
            next += count;
            connection.SendPacket(new TCDoodadStreamPacket(requestId, next, res));
        }
Exemplo n.º 31
0
    // Start is called before the first frame update
    IEnumerator Start()
    {
        spawners.Add(this);
        yield return(null);

        yield return(null);

        transform.position = new Vector3(GameSettings.MapSize.x / 2, 0, GameSettings.MapSize.y / 2);

        Instantiate(Resources.Load("Crab"), transform.position + Vector3.down * 5f, Quaternion.identity);
        Instantiate(Resources.Load("Bird"), transform.position + Vector3.down * 5f, Quaternion.identity);

        if (Team == GameSettings.Team.Red)
        {
            transform.position = new Vector3(-transform.position.x, 0, transform.position.z);
        }

        var pos = new int2(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.z));

        for (int x = pos.x - 3; x < pos.x + 4; ++x)
        {
            for (int y = pos.y - 3; y < pos.y + 4; ++y)
            {
                var go = Doodad.GetDoodadAtLocation(new int2(x, y));
                if (go)
                {
                    Destroy(go);
                }
            }
        }

        foreach (var(playerID, info) in GameSettings.GetPlayers(Team))
        {
            var go = Instantiate(Resources.Load <GameObject>("Player"));
            go.TryFind(out Player player);
            player.GamePad        = new GamePad(playerID);
            player.Team           = Team;
            go.transform.position = new Vector3(pos.x > 0 ? pos.x - 1 : pos.x + 1, 1, pos.y + playerID);
        }

        Instantiate(ShipPartPrefabs.Instance.LandingGear, transform.position, Quaternion.identity).Find <ShipAssembler>().Team = Team;
        new GameObject("Part Spawner").AddComponent <PartSpawner>().SpawnerPosition = transform.position;
    }
Exemplo n.º 32
0
 //Doodad may have their own struct later on and moved into a global
 private void PlaceDoodad(TileType[,] area, Doodad fill, int x_coord, int y_coord, int size_x, int size_y)
 {
     /*
     if (area.GetLength (0) > x_coord + size_x - 1 && area.GetLength (1) > y_coord + size_y - 1) {
         switch(fill){
         case Doodad.Gate:
             area[x_coord, y_coord] = TileType.NorthGate1;
             area[x_coord + 1, y_coord] = TileType.NorthGate2;
             break;
         default:
             break;
         }
     }
     */
 }
Exemplo n.º 33
0
        public override void WireScriptsAndValidate()
        {
            Expect.IsNotNullOrEmpty(this.jsonId, "JsonId must be explicitly set: " + this.ToString());
            this.DomId = this.JsonId;
            DatabaseAgent agent = GetAgent();
            this.tree = Doodad.GetDoodad(this.JsonId, agent);

            this.OnFolderOptionClicked = "JSUI." + this.JsonId + ".folderAction"; // in datatree.util.js
            this.OnFileOptionClicked = "JSUI." + this.JsonId + ".fileAction";
            base.WireScriptsAndValidate();
        }
Exemplo n.º 34
0
        private void LoadMap(string map, int centerx, int centery, int distance)
        {
            float TileSize = 1600.0f / 3.0f; //533.333
            float ChunkSize = TileSize / 16.0f; //33.333
            float UnitSize = ChunkSize / 8.0f; //4.166666 // ~~fun fact time with marlamin~~ this times 0.5 ends up being pixelspercoord on minimap
            float MapMidPoint = 32.0f / ChunkSize;

            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.NormalArray);

            List<Vertex> verticelist = new List<Vertex>();
            List<Int32> indicelist = new List<Int32>();

            GL.Enable(EnableCap.Texture2D);

            for (int x = centerx; x < centerx + distance; x++)
            {
                for (int y = centery; y < centery + distance; y++)
                {
                    string filename = "World/Maps/" + map + "/" + map + "_" + y + "_" + x + ".adt";

                    if (WoWFormatLib.Utils.CASC.FileExists(filename))
                    {
                        ADTReader reader = new ADTReader();
                        reader.LoadADT(filename);

                        Terrain adt = new Terrain();

                        adt.vertexBuffer = GL.GenBuffer();
                        adt.indiceBuffer = GL.GenBuffer();

                        GL.BindBuffer(BufferTarget.ArrayBuffer, adt.vertexBuffer);
                        GL.BindBuffer(BufferTarget.ElementArrayBuffer, adt.indiceBuffer);

                        List<Material> materials = new List<Material>();

                        //Check if textures are already loaded or not, multiple ADTs close together probably use the same ones mostly
                        for (int ti = 0; ti < reader.adtfile.textures.filenames.Count(); ti++)
                        {
                            Material material = new Material();
                            material.filename = reader.adtfile.textures.filenames[ti];

                            //if (!WoWFormatLib.Utils.CASC.FileExists(material.filename)) { continue; }

                            material.textureID = BLPLoader.LoadTexture(reader.adtfile.textures.filenames[ti], cache);

                            materials.Add(material);
                        }

                        var initialChunkY = reader.adtfile.chunks[0].header.position.Y;
                        var initialChunkX = reader.adtfile.chunks[0].header.position.X;

                        /*  if(firstLocation.X == 0)
                          {
                              firstLocation = new Vector3(initialChunkY, initialChunkX, 1.0f);
                              Console.WriteLine("Setting first location to " + firstLocation.ToString());
                          }
                          */
                        List<RenderBatch> renderBatches = new List<RenderBatch>();

                        for (uint c = 0; c < reader.adtfile.chunks.Count(); c++)
                        {
                            var chunk = reader.adtfile.chunks[c];

                            int off = verticelist.Count();

                            RenderBatch batch = new RenderBatch();

                            for (int i = 0, idx = 0; i < 17; i++)
                            {
                                for (int j = 0; j < (((i % 2) != 0) ? 8 : 9); j++)
                                {
                                    //var v = new Vector3(chunk.header.position.Y - (j * UnitSize), chunk.vertices.vertices[idx++] + chunk.header.position.Z, -(chunk.header.position.X - (i * UnitSize * 0.5f)));
                                    Vertex v = new Vertex();
                                    v.Normal = new Vector3(chunk.normals.normal_0[idx], chunk.normals.normal_1[idx], chunk.normals.normal_2[idx]);
                                    if (chunk.vertexShading.red != null && chunk.vertexShading.red[idx] != 127)
                                    {
                                        v.Color = new Vector3(chunk.vertexShading.blue[idx] / 255.0f, chunk.vertexShading.green[idx] / 255.0f, chunk.vertexShading.red[idx] / 255.0f);
                                        //v.Color = new Vector3(1.0f, 1.0f, 1.0f);
                                    }
                                    else
                                    {
                                        v.Color = new Vector3(1.0f, 1.0f, 1.0f);
                                    }

                                    v.TexCoord = new Vector2(((float)j + (((i % 2) != 0) ? 0.5f : 0f)) / 8f, ((float)i * 0.5f) / 8f);

                                    v.Position = new Vector3(chunk.header.position.Y - (j * UnitSize), chunk.vertices.vertices[idx++] + chunk.header.position.Z, chunk.header.position.X - (i * UnitSize * 0.5f));

                                    if ((i % 2) != 0) v.Position.X -= 0.5f * UnitSize;
                                    verticelist.Add(v);
                                }
                            }

                            batch.firstFace = (uint)indicelist.Count();
                            for (int j = 9; j < 145; j++)
                            {
                                indicelist.AddRange(new Int32[] { off + j + 8, off + j - 9, off + j });
                                indicelist.AddRange(new Int32[] { off + j - 9, off + j - 8, off + j });
                                indicelist.AddRange(new Int32[] { off + j - 8, off + j + 9, off + j });
                                indicelist.AddRange(new Int32[] { off + j + 9, off + j + 8, off + j });
                                if ((j + 1) % (9 + 8) == 0) j += 9;
                            }
                            batch.numFaces = (uint)(indicelist.Count()) - batch.firstFace;

                            if (!cache.materials.ContainsKey(reader.adtfile.textures.filenames[reader.adtfile.texChunks[c].layers[0].textureId].ToLower()))
                            {
                                throw new Exception("MaterialCache does not have texture " + reader.adtfile.textures.filenames[reader.adtfile.texChunks[c].layers[0].textureId].ToLower());
                            }

                            var layermats = new List<uint>();
                            var alphalayermats = new List<int>();

                            for (int li = 0; li < reader.adtfile.texChunks[c].layers.Count(); li++)
                            {
                                if(reader.adtfile.texChunks[c].alphaLayer != null){
                                    alphalayermats.Add(BLPLoader.GenerateAlphaTexture(reader.adtfile.texChunks[c].alphaLayer[li].layer));

                                }
                                layermats.Add((uint)cache.materials[reader.adtfile.textures.filenames[reader.adtfile.texChunks[c].layers[li].textureId].ToLower()]);
                            }

                            batch.materialID = layermats.ToArray();
                            batch.alphaMaterialID = alphalayermats.ToArray();
                            renderBatches.Add(batch);
                        }

                        List<Doodad> doodads = new List<Doodad>();

                        for (int mi = 0; mi < reader.adtfile.objects.models.entries.Count(); mi++)
                        {
                            Console.WriteLine("Loading model #" + mi);

                            var modelentry = reader.adtfile.objects.models.entries[mi];
                            var mmid = reader.adtfile.objects.m2NameOffsets.offsets[modelentry.mmidEntry];

                            var modelfilename = "";
                            for (int mmi = 0; mmi < reader.adtfile.objects.m2Names.offsets.Count(); mmi++)
                            {
                                if (reader.adtfile.objects.m2Names.offsets[mmi] == mmid)
                                {
                                    modelfilename = reader.adtfile.objects.m2Names.filenames[mmi].ToLower();
                                }
                            }

                            var doodad = new Doodad();
                            doodad.filename = modelfilename;
                            doodad.position = new Vector3(-(modelentry.position.X - 17066), modelentry.position.Y, -(modelentry.position.Z - 17066));
                            doodad.rotation = new Vector3(modelentry.rotation.X, modelentry.rotation.Y, modelentry.rotation.Z);
                            doodad.scale = modelentry.scale;
                            doodads.Add(doodad);

                            if (cache.doodadBatches.ContainsKey(modelfilename))
                            {
                                continue;
                            }

                            M2Loader.LoadM2(modelfilename, cache);
                        }

                        List<WorldModelBatch> worldModelBatches = new List<WorldModelBatch>();

                        // WMO loading goes here
                        for (int wmi = 0; wmi < reader.adtfile.objects.worldModels.entries.Count(); wmi++)
                        {
                            Console.WriteLine("Loading WMO #" + wmi);
                            string wmofilename = "";

                            var wmodelentry = reader.adtfile.objects.worldModels.entries[wmi];
                            var mwid = reader.adtfile.objects.wmoNameOffsets.offsets[wmodelentry.mwidEntry];

                            for (int wmfi = 0; wmfi < reader.adtfile.objects.wmoNames.offsets.Count(); wmfi++)
                            {
                                if (reader.adtfile.objects.wmoNames.offsets[wmfi] == mwid)
                                {
                                    wmofilename = reader.adtfile.objects.wmoNames.filenames[wmfi].ToLower();
                                }

                            }

                            if (wmofilename.Length == 0)
                            {
                                throw new Exception("Unable to find filename for WMO!");
                            }

                            WorldModelBatch wmobatch = new WorldModelBatch();
                            wmobatch.position = new Vector3(-(wmodelentry.position.X - 17066), wmodelentry.position.Y, -(wmodelentry.position.Z - 17066));
                            wmobatch.rotation = new Vector3(wmodelentry.rotation.X, wmodelentry.rotation.Y, wmodelentry.rotation.Z);
                            wmobatch.worldModel = WMOLoader.LoadWMO(wmofilename, cache);
                            worldModelBatches.Add(wmobatch);
                        }

                        adt.renderBatches = renderBatches.ToArray();
                        adt.doodads = doodads.ToArray();
                        adt.worldModelBatches = worldModelBatches.ToArray();

                        int[] indices = indicelist.ToArray();
                        Vertex[] vertices = verticelist.ToArray();

                        Console.WriteLine("Vertices in array: " + vertices.Count()); //37120, correct

                        //indices = indicelist.ToArray();
                        Console.WriteLine("Indices in array: " + indices.Count()); //196608, should be 65.5k which is 196608 / 3. in triangles so its correct?

                        GL.BindBuffer(BufferTarget.ArrayBuffer, adt.vertexBuffer);
                        GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertices.Count() * 11 * sizeof(float)), vertices, BufferUsageHint.StaticDraw);

                        GL.BindBuffer(BufferTarget.ElementArrayBuffer, adt.indiceBuffer);
                        GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(indices.Length * sizeof(int)), indices, BufferUsageHint.StaticDraw);

                        int verticeBufferSize = 0;
                        int indiceBufferSize = 0;

                        GL.BindBuffer(BufferTarget.ArrayBuffer, adt.vertexBuffer);
                        GL.GetBufferParameter(BufferTarget.ArrayBuffer, BufferParameterName.BufferSize, out verticeBufferSize);

                        GL.BindBuffer(BufferTarget.ArrayBuffer, adt.indiceBuffer);
                        GL.GetBufferParameter(BufferTarget.ElementArrayBuffer, BufferParameterName.BufferSize, out indiceBufferSize);

                        Console.WriteLine("Vertices in buffer: " + verticeBufferSize / 11 / sizeof(float));
                        Console.WriteLine("Indices in buffer: " + indiceBufferSize / sizeof(int));

                        adts.Add(adt);
                    }
                }
            }
        }
Exemplo n.º 35
0
        public static HtmlGenericControl GetHtmlTreeFrom(Doodad tree, string jsonId)
        {
            HtmlGenericControl topLevelUL = new HtmlGenericControl("ul");
            topLevelUL.Attributes.Add("class", "filetree");
            topLevelUL.Style.Add("display", "none");
            topLevelUL.Attributes.Add("jsonid", jsonId);
            foreach (Node node in tree.Folders)
            {
                topLevelUL.Controls.Add(GetHtmlFolderNode(node, jsonId));
            }

            foreach (Node node in tree.Files)
            {
                topLevelUL.Controls.Add(GetHtmlFileNode(node));
            }

            return topLevelUL;
        }
Exemplo n.º 36
0
 private HtmlGenericControl GetHtmlTreeFrom(Doodad tree)
 {
     return GetHtmlTreeFrom(tree, this.JsonId);
 }
Exemplo n.º 37
0
        public void render_doodads_to_board(ref List<Doodad> fl_doodads, int fl_size, ContentManager cmgr, FloorBuilder flb)
        {
            for (int i = 0; i < doodad_list.Count; i++)
            {
                gridCoordinate doodad_coord = doodad_list[i].Value;
                gridCoordinate new_doodad_coord = new gridCoordinate(doodad_coord.x + startXPos,
                                                                     doodad_coord.y + startYPos);

                if(!flb.is_tile_obstructed(new_doodad_coord))
                    fl_doodads.Add(new Doodad(doodad_list[i].Key, cmgr, new_doodad_coord, fl_doodads.Count));
            }

            if (bonus_gold > 0)
            {
                gridCoordinate tbox_gc = new gridCoordinate(-1, -1);
                List<gridCoordinate> potential_tbox_spots = new List<gridCoordinate>();
                for (int x = 0; x < roomWidth; x++)
                {
                    gridCoordinate target_gc = new gridCoordinate(startXPos + x, startYPos);
                    gridCoordinate target_gc_2 = new gridCoordinate(startXPos + x, startYPos + roomHeight - 1);
                    if(!flb.is_tile_obstructed(target_gc))
                        potential_tbox_spots.Add(target_gc);
                    if (!flb.is_tile_obstructed(target_gc_2))
                        potential_tbox_spots.Add(target_gc_2);
                }

                for (int y = 0; y < roomHeight; y++)
                {
                    gridCoordinate target_gc = new gridCoordinate(startXPos, startYPos + y);
                    gridCoordinate target_gc_2 = new gridCoordinate(startXPos + roomWidth - 1, startYPos + y);
                    if (!flb.is_tile_obstructed(target_gc))
                        potential_tbox_spots.Add(target_gc);
                    if (!flb.is_tile_obstructed(target_gc_2))
                        potential_tbox_spots.Add(target_gc_2);
                }

                if (potential_tbox_spots.Count > 0)
                    tbox_gc = potential_tbox_spots[rGen.Next(potential_tbox_spots.Count)];
                else
                    tbox_gc = flb.random_valid_position(fl_size);

                Doodad treasure_box = new Doodad(Doodad.Doodad_Type.TreasureBox, cmgr, tbox_gc, fl_doodads.Count);
                treasure_box.set_chest_contents(bonus_gold);
                fl_doodads.Add(treasure_box);
            }
        }
Exemplo n.º 38
0
 private void GenerateRandomMass(TileType[,] area, Doodad fill, int x_coord, int y_coord, int kFactor, int cFactor, int radius)
 {
     area[x_coord, y_coord] = TileType.Poop;
     InverseSpiralGeneration (area, TileType.Poop, x_coord, y_coord, kFactor, cFactor, radius);
 }
Exemplo n.º 39
0
    //Reserved a plot of land for example a larger tree or a building or a bandit camp
    private void FillWithTile(TileType[,] area, TileType scanTarget, Doodad fill, int acceptedClearance, int size_x, int size_y)
    {
        /*
        int x_coord = 0;
        int y_coord = 0;
        int perimeter = 2 * size_x + 2 * size_y;
        bool clearance = false;

        if(acceptedClearance <= perimeter){
            do{
                x_coord = (int)Random.Range (0, _tileData.GetLength(0) - size_x);
                y_coord = (int)Random.Range (0, _tileData.GetLength(1) - size_y);
                if(ScanEdge(area, scanTarget, size_x, size_y, x_coord, y_coord) >= acceptedClearance)
                    clearance = true;
            }while(!clearance);
            if(clearance){
                //Check
                PlaceDoodadHolder (area, size_x, size_y, x_coord, y_coord);

                switch(fill){
                case Doodad.Dirt:
                    area[x_coord, y_coord] = TileType.DirtToGrassBL;
                    area[x_coord + size_x - 1, y_coord] = TileType.DirtToGrassBR;
                    area[x_coord, y_coord + size_y - 1] = TileType.DirtToGrassTL;
                    area[x_coord + size_x - 1, y_coord + size_y - 1] = TileType.DirtToGrassTR;
                    for (int y = y_coord + 1; y < y_coord + size_y - 1; y++){
                        area[x_coord, y] = TileType.DirtToGrassL;
                        area[x_coord + size_x - 1 , y] = TileType.DirtToGrassR;
                    }
                    for (int x = x_coord + 1; x < x_coord + size_x - 1; x++){
                        area[x, y_coord] = TileType.DirtToGrassB;
                        area[x, y_coord + size_y - 1] = TileType.DirtToGrassT;
                    }
                    for (int y = y_coord + 1; y < y_coord + size_y - 1; y++)
                        for (int x = x_coord +1; x < x_coord + size_x - 1; x++)
                            area[x, y] = TileType.Dirt;
                    break;
                default:
                    break;

                }
            }
        }
        */
    }
Exemplo n.º 40
0
        public void bash_attack(Floor fl, Monster m, gridCoordinate target_coord, Doodad d, Weapon wp)
        {
            bool rolled_max = false;
            int xdif = 0;
            int ydif = 0;
            if (m != null)
            {
                xdif = target_coord.x - my_grid_coord.x;
                ydif = target_coord.y - my_grid_coord.y;
            }
            else
            {
                xdif = d.get_g_coord().x - my_grid_coord.x;
                ydif = d.get_g_coord().y - my_grid_coord.y;
            }

            double multiplier = 1.4;
            if (wp.get_hand_count() == 2)
                multiplier = 1.6;

            int m_hp = 0;
            if(m!= null)
                m_hp = m.hitPoints;

            gridCoordinate opposition_coord = new gridCoordinate(-1, -1);
            if(m != null)
                opposition_coord = target_coord;
            else
                opposition_coord = d.get_g_coord();

            fl.add_effect(wp.get_my_damage_type(), opposition_coord);
            if (m != null)
                attack_monster_in_grid(fl, wp, m.my_Index, target_coord, multiplier, out rolled_max);
            else
                attack_Doodad_in_grid(fl, wp, d.get_my_index(), d.get_g_coord(), multiplier, out rolled_max);

            if (m!= null && m.hitPoints > 0 && m_hp > m.hitPoints)
            {
                if(!m.shove(xdif, ydif, this, fl))
                {
                    fl.add_effect(wp.get_my_damage_type(), target_coord);
                    attack_monster_in_grid(fl, wp, m.my_Index, target_coord, 0.5, out rolled_max);
                }
            }
            wp.set_cooldown(standard_wpn_cooldown);

            if (my_class == Chara_Class.Warrior)
            {
                c_energy += 5 + rGen.Next(2);
                if (rolled_max)
                    c_energy++;
            }
        }