Exemplo n.º 1
0
    void SetMode(string modeName)
    {
        if (objectInfo.draw)
        {
            int newMode = System.Array.IndexOf(COF.ModeNames[2], modeName);
            if (newMode == -1 || !objectInfo.mode[newMode])
            {
                Debug.LogWarning("Failed to set mode '" + modeName + "' of object " + name);
                return;
            }

            if (objectInfo.hasCollision[mode])
            {
                CollisionMap.SetPassable(Iso.Snap(iso.pos), objectInfo.sizeX, objectInfo.sizeY, true, gameObject);
            }

            mode = newMode;

            var cof = COF.Load(@"data\global\objects", objectInfo.token, "HTH", modeName);
            animator.shadow = objectInfo.blocksLight[mode];
            animator.cof    = cof;
            animator.loop   = objectInfo.cycleAnim[mode];
            animator.SetFrameRange(objectInfo.start[mode], objectInfo.frameCount[mode]);
            animator.frameDuration = objectInfo.frameDuration[mode];

            if (objectInfo.hasCollision[mode])
            {
                CollisionMap.SetPassable(Iso.Snap(iso.pos), objectInfo.sizeX, objectInfo.sizeY, false, gameObject);
            }
        }
    }
Exemplo n.º 2
0
        private void Update()
        {
            var info = _staticObject.info;
            var mode = _staticObject.Mode;

            if (!info.mode[mode.index])
            {
                _renderer.cof = null;
                return;
            }

            if (_renderer.cof == null || _renderer.cof.mode != mode.token)
            {
                var cof = COF.Load(@"data\global\objects", info.token, "HTH", mode.token);
                _renderer.shadow = info.blocksLight[mode.index];
                _renderer.cof    = cof;
            }

            int frame = (int)(_staticObject.AnimationTime * info.frameCount[mode.index] / _staticObject.AnimationDuration);

            frame           = Mathf.Min(frame, info.frameCount[mode.index]);
            frame           = Mathf.Max(frame, 0);
            frame          += info.start[mode.index];
            _renderer.frame = frame;
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("COFId,COFNumber,Issued,Expired,Remarks")] COF cOF)
        {
            if (id != cOF.COFId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cOF);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!COFExists(cOF.COFId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cOF));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("COFId,COFNumber,Issued,Expired,Remarks")] COF cOF)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cOF);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cOF));
        }
Exemplo n.º 5
0
        private void Update()
        {
            var    mode        = _unit.Mode;
            string weaponClass = _unit.weaponClass;

            if (mode == "DT" || mode == "DD")
            {
                weaponClass = "HTH";
            }

            _renderer.cof       = COF.Load(_unit.basePath, _unit.token, weaponClass, mode);
            _renderer.direction = _unit.DirectionIndex;
            _renderer.frame     = _unit.AnimationFrame;
        }
Exemplo n.º 6
0
        void UpdateAnimation()
        {
            string mode        = Mode;
            string weaponClass = this.weaponClass;

            _animator.speed = 1.0f;
            _animator.loop  = true;
            if (mode == "DT" || mode == "DD")
            {
                weaponClass    = "HTH";
                _animator.loop = false;
            }

            _animator.cof       = COF.Load(basePath, token, weaponClass, mode);
            _animator.direction = _directionIndex;
        }
Exemplo n.º 7
0
    void UpdateAnimation()
    {
        string mode;
        string weaponClass = this.weaponClass;

        animator.speed = 1.0f;
        animator.loop  = true;
        if (ressurecting && monStat != null)
        {
            mode = monStat.ext.resurrectMode;
        }
        else if (dying)
        {
            mode          = "DT";
            weaponClass   = "HTH";
            animator.loop = false;
        }
        else if (dead)
        {
            mode          = "DD";
            weaponClass   = "HTH";
            animator.loop = false;
        }
        else if (takingDamage)
        {
            mode = "GH";
        }
        else if (hasMoved)
        {
            mode = run ? "RN" : "WL";
        }
        else if (usingSkill)
        {
            mode = skillInfo.anim;
        }
        else
        {
            mode = "NU";
        }

        animator.cof       = COF.Load(basePath, token, weaponClass, mode);
        animator.direction = directionIndex;
    }
Exemplo n.º 8
0
        static COF GetCof(CharStatsInfo info, string mode)
        {
            var basePath = @"data\global\chars";

            return(COF.Load(basePath, info.token, info.baseWClass, mode));
        }
Exemplo n.º 9
0
    static public COF Load(string basePath, string token, string weaponClass, string mode)
    {
        var filename = basePath + @"\" + token + @"\cof\" + token + mode + weaponClass + ".cof";

        if (cache.ContainsKey(filename))
        {
            return(cache[filename]);
        }

        UnityEngine.Profiling.Profiler.BeginSample("COF.Load");

        COF cof = new COF();

        cof.basePath = basePath;
        cof.token    = token;
        cof.mode     = mode;

        byte[] bytes = Mpq.ReadAllBytes(filename);
        using (var stream = new MemoryStream(bytes))
            using (var reader = new BinaryReader(stream))
            {
                cof.layerCount         = reader.ReadByte();
                cof.framesPerDirection = reader.ReadByte();
                cof.directionCount     = reader.ReadByte();
                stream.Seek(25, SeekOrigin.Current);

                cof.compositLayers = new Layer[16];
                cof.layers         = new Layer[cof.layerCount];

                for (int i = 0; i < cof.layerCount; ++i)
                {
                    Layer layer = new Layer();
                    layer.index         = i;
                    layer.compositIndex = reader.ReadByte();
                    layer.name          = layerNames[layer.compositIndex];

                    layer.shadow = reader.ReadByte() != 0;
                    reader.ReadByte();

                    bool transparent = reader.ReadByte() != 0;
                    int  blendMode   = reader.ReadByte();
                    if (transparent)
                    {
                        layer.material = Materials.softAdditive;
                    }
                    else
                    {
                        layer.material = Materials.normal;
                    }

                    layer.weaponClass = System.Text.Encoding.Default.GetString(reader.ReadBytes(4), 0, 3);

                    cof.layers[i] = layer;
                    cof.compositLayers[layer.compositIndex] = layer;
                }

                stream.Seek(cof.framesPerDirection, SeekOrigin.Current);
                cof.priority = reader.ReadBytes(cof.directionCount * cof.framesPerDirection * cof.layerCount);
            }

        AnimData animData = new AnimData();

        if (AnimData.Find(token + mode + weaponClass, ref animData))
        {
            cof.frameDuration = animData.frameDuration;
            float refFrameCount = referenceFrameCount.GetValueOrDefault(token + mode, animData.framesPerDir);
            cof.frameDuration *= animData.framesPerDir / refFrameCount;
        }
        else
        {
            Debug.LogWarning("animdata not found " + (token + mode + weaponClass));
        }

        cache.Add(filename, cof);

        UnityEngine.Profiling.Profiler.EndSample();
        return(cof);
    }
Exemplo n.º 10
0
 private void Trace(string msg) => COF.Trace(msg);