Ejemplo n.º 1
0
        /// <summary>
        /// Read monster data.
        /// </summary>
        private MonsterCFG ReadMonsterCFG(int index)
        {
            // Get reader for this monster record
            FileProxy    proxy  = bsaFile.GetRecordProxy(index);
            BinaryReader reader = proxy.GetReader();

            // Read monster resist, etc. flags
            MonsterCFG cfg = new MonsterCFG();

            cfg.ResistanceFlags       = reader.ReadByte();
            cfg.ImmunityFlags         = reader.ReadByte();
            cfg.LowToleranceFlags     = reader.ReadByte();
            cfg.CriticalWeaknessFlags = reader.ReadByte();

            // Read monster special ability and spell point bitfield
            cfg.AbilityFlagsAndSpellPointsBitfield = reader.ReadInt16();

            // Read 22 unknown bytes for UnknownRange1
            cfg.UnknownRange1 = reader.ReadBytes(22);

            // Read name
            cfg.Name = proxy.ReadCStringSkip(reader, 0, 16);

            // Read 30 unknown bytes for UnknownRange2
            cfg.UnknownRange2 = reader.ReadBytes(30);

            return(cfg);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load monster record into memory and decompose it for use.
        /// </summary>
        /// <param name="monster">Monster index.</param>
        /// <returns>True if successful.</returns>
        public bool LoadMonster(int monster, out DFMonster dfMonster)
        {
            dfMonster = new DFMonster();

            // Generate name from index
            string name = string.Format("ENEMY{0:000}.CFG", monster);

            // Attempt to load record
            int index = bsaFile.GetRecordIndex(name);

            if (index == -1)
            {
                return(false);
            }

            // Read monster CFG data
            MonsterCFG cfg = ReadMonsterCFG(index);

            dfMonster.MonsterCFG = cfg;

            // Copy name, resists, etc.
            dfMonster.Name                  = cfg.Name;
            dfMonster.ResistanceFlags       = cfg.ResistanceFlags;
            dfMonster.ImmunityFlags         = cfg.ImmunityFlags;
            dfMonster.LowToleranceFlags     = cfg.LowToleranceFlags;
            dfMonster.CriticalWeaknessFlags = cfg.CriticalWeaknessFlags;

            // Expand special abilities, spell points, etc.
            int value = cfg.AbilityFlagsAndSpellPointsBitfield;

            dfMonster.AcuteHearing         = ((value & 1) == 1);
            dfMonster.Athleticism          = ((value & 2) == 2);
            dfMonster.AdrenalineRush       = ((value & 4) == 4);
            dfMonster.NoRegenSpellPoints   = ((value & 8) == 8);
            dfMonster.SunDamage            = ((value & 16) == 16);
            dfMonster.HolyDamage           = ((value & 32) == 32);
            dfMonster.SpellPointsInDark    = ((value & 0x00c0) >> 8);
            dfMonster.SpellPointsInLight   = ((value & 0x0300) >> 10);
            dfMonster.SpellPointMultiplier = ((value & 0x1c00) >> 12);

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Read monster data.
        /// </summary>
        private MonsterCFG ReadMonsterCFG(int index)
        {
            // Get reader for this monster record
            FileProxy proxy = bsaFile.GetRecordProxy(index);
            BinaryReader reader = proxy.GetReader();

            // Read monster resist, etc. flags
            MonsterCFG cfg = new MonsterCFG();
            cfg.ResistanceFlags = reader.ReadByte();
            cfg.ImmunityFlags = reader.ReadByte();
            cfg.LowToleranceFlags = reader.ReadByte();
            cfg.CriticalWeaknessFlags = reader.ReadByte();

            // Read monster special ability and spell point bitfield
            cfg.AbilityFlagsAndSpellPointsBitfield = reader.ReadInt16();

            // Read 22 unknown bytes for UnknownRange1
            cfg.UnknownRange1 = reader.ReadBytes(22);

            // Read name
            cfg.Name = proxy.ReadCStringSkip(reader, 0, 16);

            // Read 30 unknown bytes for UnknownRange2
            cfg.UnknownRange2 = reader.ReadBytes(30);

            return cfg;
        }
Ejemplo n.º 4
0
        protected override void drawSceneGUI()
        {
            List <SpawersZoneVO> list = mTarget.list;

            if (list == null || list.Count <= 0)
            {
                return;
            }

            Event e         = Event.current;
            bool  isMouseUp = false;

            if (e.type == EventType.MouseUp)
            {
                isMouseUp = true;
            }
            bool isShift = e.shift;

            Vector3 position;
            int     len = list.Count;

            bool isCurrentZoom = false;
            bool isCurrentWave = false;

            Color color   = Color.red;
            float centerY = 0;

            int[] zoomHosControl = new int[len];
            for (int i = 0; i < len; i++)
            {
                isCurrentZoom = zoomIndex == i;
                SpawersZoneVO spawersZoneVo = list[i];
                Rect          rect          = spawersZoneVo.rect;
                position = new Vector3(rect.center.x, 0, rect.center.y);

                if (isCurrentZoom == false)
                {
                    color.a = 0.3f;
                }
                else
                {
                    color.a = 1.0f;
                }
                Handles.color = color;
                GUI.color     = color;

                Vector3 rectCenter = new Vector3(rect.x, 0, rect.y);
                //Vector3 rectSize = new Vector3(rect.width, 0, rect.height);

                verts[0] = new Vector3(rect.x - rect.width / 2f, centerY, rect.y - rect.height / 2f);
                verts[1] = new Vector3(rect.x + rect.width / 2f, centerY, rect.y - rect.height / 2f);
                verts[2] = new Vector3(rect.x + rect.width / 2f, centerY, rect.y + rect.height / 2f);
                verts[3] = new Vector3(rect.x - rect.width / 2f, centerY, rect.y + rect.height / 2f);

                Handles.DrawSolidRectangleWithOutline(verts, rectSolideColor, Color.gray);

                float   size = HandleUtility.GetHandleSize(rectCenter) * controlSize;
                Vector3 newPos;

                newPos = Handles.FreeMoveHandle(rectCenter, Quaternion.identity, size / 2, Vector3.zero,
                                                (controlID, p, rotation, s, evenType) =>
                {
                    zoomHosControl[i] = controlID;
                    Handles.DotHandleCap(controlID, p, rotation, s, evenType);
                });

                if (GUIUtility.hotControl == zoomHosControl[i])
                {
                    if (isShift)
                    {
                        Vector2 v        = Event.current.mousePosition;
                        Ray     ray      = HandleUtility.GUIPointToWorldRay(v);
                        Vector3 rayPoint = ray.origin;
                        Handles.DrawLine(rectCenter, rayPoint);

                        if (isMouseUp)
                        {
                            SpawersZoneVO refVector2 =
                                mTarget.getNearSpawersZoneCfg(new Vector2(rayPoint.x, rayPoint.z));
                            if (refVector2 != null)
                            {
                                KeyVector2 intVector2 = new KeyVector2();
                                intVector2.x = spawersZoneVo.getGUID();
                                intVector2.y = refVector2.getGUID();
                                mTarget.addConn(intVector2);
                            }
                            isMouseUp = false;
                        }
                    }
                    else if (GUIUtility.hotControl != 0)
                    {
                        zoomIndex = i;
                        Repaint();
                    }
                }

                if (rectCenter != newPos && isCurrentZoom && isShift == false)
                {
                    Undo.RecordObject(mTarget, "ZoneMove");
                    rect.x             = newPos.x;
                    rect.y             = newPos.z;
                    spawersZoneVo.rect = rect;
                }

                int jLen = spawersZoneVo.list.Count;
                for (int j = 0; j < jLen; j++)
                {
                    WaveCFG waveCfg = spawersZoneVo.list[j];
                    isCurrentWave = isCurrentZoom && (j == waveIndex);
                    int kLen = waveCfg.list.Count;

                    int[] monsterHosControl = new int[kLen];
                    for (int k = 0; k < kLen; k++)
                    {
                        MonsterCFG monsterCfg = waveCfg.list[k];
                        position = rectCenter + new Vector3(monsterCfg.position.x, 0, monsterCfg.position.y);
                        if (isCurrentWave && isShift == false)
                        {
                            size   = HandleUtility.GetHandleSize(position) * controlSize;
                            newPos = Handles.FreeMoveHandle(position, Quaternion.identity, size, Vector3.zero,
                                                            (int controlID, Vector3 pos, Quaternion rotation, float s, EventType et) =>
                            {
                                monsterHosControl[k] = controlID;
                                if (k == monsterIndex)
                                {
                                    Handles.color = Color.green;
                                }
                                Handles.SphereHandleCap(controlID, pos, rotation, s, et);
                                Handles.color = color;
                            });

                            if (GUIUtility.hotControl == monsterHosControl[k] && GUIUtility.hotControl != 0)
                            {
                                monsterIndex = k;
                                Repaint();
                            }

                            Quaternion q = Quaternion.Euler(0, monsterCfg.euler, 0);
                            Handles.ArrowHandleCap(0, position, q, size, Event.current.type);

                            if (position != newPos)
                            {
                                Undo.RecordObject(mTarget, "MonsterMove");
                                Vector3 p = newPos - rectCenter;
                                monsterCfg.position = new Vector2(p.x, p.z);
                            }
                        }

                        Color oldColor = GUI.color;
                        GUI.color = Color.white;
                        string monsterId = monsterCfg.id;
                        if (string.IsNullOrEmpty(monsterId))
                        {
                            monsterId = "#" + (j + 1) + "#";
                        }
                        Handles.Label(position, monsterId);
                        GUI.color = oldColor;
                    }
                }

                GUI.color = Color.white;
                Handles.Label(rectCenter, "Zone" + (i + 1), headStyle.zoomText);
            }
            GUI.color = Color.white;


            Handles.color = Color.green;
            List <KeyVector2> todoRemove = new List <KeyVector2>();

            foreach (KeyVector2 item in mTarget.connList)
            {
                SpawersZoneVO a = mTarget.getSpawersZoneCfgByGUID(item.x);
                SpawersZoneVO b = mTarget.getSpawersZoneCfgByGUID(item.y);
                if (a == null || b == null)
                {
                    todoRemove.Add(item);
                    continue;
                }
                Handles.DrawLine(new Vector3(a.rect.x, 0, a.rect.y), new Vector3(b.rect.x, 0, b.rect.y));
            }

            if (todoRemove.Count > 0)
            {
                foreach (KeyVector2 item in todoRemove)
                {
                    int tIndex = mTarget.connList.IndexOf(item);
                    if (tIndex != -1)
                    {
                        mTarget.connList.RemoveAt(tIndex);
                    }
                }
                serializedObject.ApplyModifiedProperties();
            }
        }