コード例 #1
0
ファイル: ActionField.cs プロジェクト: Spierek/SpyChess
    public virtual void Set(Piece piece, FieldScript field)
    {
        this.piece = piece;
        this.field = field;

        transform.position = field.transform.position;
    }
コード例 #2
0
ファイル: Piece.cs プロジェクト: Spierek/SpyChess
    // INTERACTION
    public void Move(FieldScript newField)
    {
        FieldScript currentField = GameController.Instance.board.GetField(currentPos.x, currentPos.y);

        currentField.Free();
        newField.Occupy(this);

        currentPos = newField.pos;

        // animate movement
        transform.DOMove(newField.transform.position, 0.5f).SetEase(Ease.InOutCubic);

        GameController.Instance.NextTurn();
        Deselect();
    }
コード例 #3
0
    private void Update()
    {
        putChecker();
        showPossibleMoves();
        moveChecker();
        removeChecker();

        if (Input.GetKeyDown(KeyCode.Mouse1))
        {
            Vector2Int?pos = getMouseToBoardPos();
            if (_chackers != null && pos != null && _chackers[pos.Value.x, pos.Value.y] == null)
            {
                _toEnd = getField(pos.Value.x, pos.Value.y).script;
                _toEnd.StartParticle();
            }
        }

        if (Input.GetKeyUp(KeyCode.Mouse1) && _toEnd)
        {
            _toEnd.EndParticle();
        }
    }
コード例 #4
0
        public static void Apply(FileSource fieldSource, Dictionary <int, int> shuffle)
        {
            var musicOps = new int[] { FieldScript.OpCodesReverse["setbattlemusic"], FieldScript.OpCodesReverse["musicload"] };

            // load list of scripts to search for music changes
            var scripts = MusicLoads.Select(m => new Tuple <string, int, int>(m.FieldName, m.Entity, m.Script)).ToList();

            // add any extra changes from free roam boss clouds
            scripts.AddRange(Boss.Bosses.Where(b => !string.IsNullOrEmpty(b.FieldID)).Select(b => new Tuple <string, int, int>(b.FieldID, b.FieldEntity, b.FieldScript)));

            // remove duplicates
            scripts = scripts.Distinct().ToList();

            // search all these scripts & replace the music IDs with random ones
            foreach (var fieldName in scripts.Select(s => s.Item1).Distinct())
            {
                var field = FieldScript.FromSource(fieldSource, fieldName);

                foreach (var s in scripts.Where(s => s.Item1 == fieldName))
                {
                    var script = field.Entities[s.Item2].Scripts[s.Item3];
                    for (int i = 0; i < script.Instructions.Count; i++)
                    {
                        if (musicOps.Contains(script.Instructions[i].OpCode) && i > 0)
                        {
                            // update the previous instruction (where the track ID is pushed onto the stack)
                            var prevParam = script.Instructions[i - 1].Param;
                            if (shuffle.ContainsKey(prevParam))
                            {
                                field.Entities[s.Item2].Scripts[s.Item3].Instructions[i - 1].Param = shuffle[prevParam];
                            }
                        }
                    }
                }

                field.SaveToSource(fieldSource, fieldName);
            }
        }
コード例 #5
0
        public static void Apply(FileSource fieldSource, Dictionary <int, int> shuffle)
        {
            // take a script from the start field
            var scriptField  = "start0";
            var scriptEntity = 0;
            var scriptId     = 0;
            var script       = App.ReadEmbeddedFile(string.Format("FF8Mod.Maelstrom.FieldScripts.{0}.{1}.{2}.txt", scriptField, scriptEntity, scriptId));

            // move cards to their assigned decks
            foreach (var card in shuffle.Keys)
            {
                // if you getcard before you setcard, it reveals the location in the card menu
                // script += Environment.NewLine + GetCard(i);

                script += Environment.NewLine + SetCard(shuffle[card], card);
            }

            // save the script
            var field = FieldScript.FromSource(fieldSource, scriptField);

            field.ReplaceScript(scriptEntity, scriptId, script);
            StorySkip.SaveToSource(fieldSource, scriptField, field.Encode()); // todo: put this somewhere more sensible
        }
コード例 #6
0
        public void FullTest2()
        {
            // load a real jsm file from the game
            var jsmFile = File.ReadAllBytes(@"TestData\bdifrit1.jsm");
            var script  = FieldScript.FromBytes(jsmFile);

            // 16 entities with all the correct scripts
            Assert.Equal(16, script.Entities.Count);
            Assert.Single(script.Entities.Where(e => e.Type == EntityType.Line).ToList());
            Assert.Empty(script.Entities.Where(e => e.Type == EntityType.Door).ToList());
            Assert.Equal(4, script.Entities.Where(e => e.Type == EntityType.Background).Count());
            Assert.Equal(11, script.Entities.Where(e => e.Type == EntityType.Other).Count());

            Assert.Equal(8, script.Entities[0].Scripts.Count);
            Assert.Equal(44, script.Entities[0].Scripts[0].Instructions[0].Param);
            Assert.Equal(2, script.Entities[1].Scripts.Count);
            Assert.Equal(56, script.Entities[1].Scripts[0].Instructions[0].Param);
            Assert.Equal(4, script.Entities[15].Scripts.Count);
            Assert.Equal(52, script.Entities[15].Scripts[0].Instructions[0].Param);

            // re-encode & run the same tests again
            script = FieldScript.FromBytes(script.Encode());

            Assert.Equal(16, script.Entities.Count);
            Assert.Single(script.Entities.Where(e => e.Type == EntityType.Line).ToList());
            Assert.Empty(script.Entities.Where(e => e.Type == EntityType.Door).ToList());
            Assert.Equal(4, script.Entities.Where(e => e.Type == EntityType.Background).Count());
            Assert.Equal(11, script.Entities.Where(e => e.Type == EntityType.Other).Count());

            Assert.Equal(8, script.Entities[0].Scripts.Count);
            Assert.Equal(44, script.Entities[0].Scripts[0].Instructions[0].Param);
            Assert.Equal(2, script.Entities[1].Scripts.Count);
            Assert.Equal(56, script.Entities[1].Scripts[0].Instructions[0].Param);
            Assert.Equal(4, script.Entities[15].Scripts.Count);
            Assert.Equal(52, script.Entities[15].Scripts[0].Instructions[0].Param);
        }
コード例 #7
0
    // Update is called once per frame
    void Update()
    {
        timerToWork += Time.deltaTime;

        if (timerToWork >= 1 && state == States.Available)
        {
            if (isThereUncultivated())
            {
                state = States.NeedsCultivating;
            }
            else if (isThereUncut() && rm.food + 10 < rm.storage)
            {
                state = States.NeedsCutting;
            }
            else if (isThereUnplanted())
            {
                state = States.NeedsPlanting;
            }

            timerToWork = 0;
        }

        switch (state)
        {
        case States.NeedsCultivating:
            currentField = getUncultivatedFields()[0];
            if (currentField == null)
            {
                state = States.CommingBack;
            }
            else
            {
                unit.MoveTo(currentField.transform.position);
                state = States.GoingToCultivate;
            }
            break;

        case States.NeedsPlanting:
            currentField = getUnplantedFields()[0];
            if (currentField == null)
            {
                state = States.CommingBack;
                unit.MoveTo(fsc.InitialPosition.transform.position);
            }
            else
            {
                unit.MoveTo(currentField.transform.position);
                state = States.GoingToPlant;
            }
            break;

        case States.GoingToPlant:
            if (ArrivedAtTarget())
            {
                state = States.Planting;
            }
            break;

        case States.Planting:
            if (currentWorkingTime < plantingTime)
            {
                currentWorkingTime += Time.deltaTime;
            }
            else
            {
                currentField.SetPlanted();
                unit.MoveTo(fsc.InitialPosition.transform.position);
                state = States.CommingBack;
                currentWorkingTime = 0;
            }
            break;

        case States.GoingToCultivate:
            if (ArrivedAtTarget())
            {
                state = States.Cultivating;
            }
            break;

        case States.Cultivating:
            if (currentWorkingTime < cultivatingTime)
            {
                currentWorkingTime += Time.deltaTime;
            }
            else
            {
                currentField.SetCultivated();
                unit.MoveTo(fsc.InitialPosition.transform.position);
                state = States.CommingBack;
                currentWorkingTime = 0;
            }
            break;

        case States.CommingBack:
            unit.MoveTo(fsc.InitialPosition.transform.position);

            if (ArrivedAtTarget())
            {
                state = States.Available;
                rm.IncreaseResources(ResourceManager.Resources.Food, carryingFood);
                carryingFood = 0;
            }
            break;

        case States.NeedsCutting:
            currentField = getUncutFields()[0];
            if (currentField == null)
            {
                state = States.CommingBack;
                unit.MoveTo(fsc.InitialPosition.transform.position);
            }
            else
            {
                unit.MoveTo(currentField.transform.position);
                state = States.GoingToCut;
            }
            break;

        case States.GoingToCut:
            if (ArrivedAtTarget())
            {
                state = States.Cutting;
            }
            break;

        case States.Cutting:
            if (currentWorkingTime < cuttingTime)
            {
                currentWorkingTime += Time.deltaTime;
            }
            else
            {
                currentField.SetCut();
                unit.MoveTo(fsc.InitialPosition.transform.position);
                state = States.CommingBack;
                currentWorkingTime = 0;
                carryingFood      += currentField.foodYield;
            }
            break;

        default:

            break;
        }
    }
コード例 #8
0
ファイル: AttackField.cs プロジェクト: Spierek/SpyChess
 public override void Set(Piece piece, FieldScript field)
 {
     base.Set(piece, field);
     targetPiece = field.currentPiece;
 }
コード例 #9
0
 static public void ClickField(int x, int y)
 {
     if (somethingSelected)
     {
         FieldScript tmpField = FindField(x, y);
         UnitScript  of       = SelectedField.InstHero.GetComponent <UnitScript>();
         if (of.Player != Round)
         {
             print("round: " + Round + "player: " + of.Player);
             return;
         }
         if (tmpField.hero != null)
         {
             UnitScript def = tmpField.InstHero.GetComponent <UnitScript>();
             if (of.Tag == Kind.simpleAttack)
             {
                 if (of.Player != def.Player)
                 {
                     float finallyAttack = of.UnitAction(def) - def.armor;
                     if (finallyAttack > 0)
                     {
                         def.life -= finallyAttack;
                     }
                 }
             }
             else if (of.Tag == Kind.heal)
             {
                 if (of.Player == def.Player)
                 {
                     def.life += of.UnitAction(def);
                 }
             }
             else if (of.Tag == Kind.areaAttack)
             {
                 List <FieldScript> tmpFields = new List <FieldScript>();
                 int tmpX = def.x;
                 int tmpY = def.y;
                 tmpFields.Add(tmpField);
                 if (((float)tmpY % 2) != 0)
                 {
                     FieldScript f1 = new FieldScript();
                     f1.x = tmpX--;
                     f1.y = tmpY--;
                     tmpFields.Add(f1);
                     FieldScript f2 = new FieldScript();
                     f2.x = tmpX;
                     f2.y = tmpY--;
                     tmpFields.Add(f2);
                     FieldScript f3 = new FieldScript();
                     f3.x = tmpX++;
                     f3.y = tmpY;
                     tmpFields.Add(f3);
                     FieldScript f4 = new FieldScript();
                     f4.x = tmpX;
                     f4.y = tmpY++;
                     tmpFields.Add(f4);
                     FieldScript f5 = new FieldScript();
                     f5.x = tmpX--;
                     f5.y = tmpY++;
                     tmpFields.Add(f5);
                     FieldScript f6 = new FieldScript();
                     f6.x = tmpX--;
                     f6.y = tmpY;
                     tmpFields.Add(f6);
                 }
                 else
                 {
                     FieldScript f1 = new FieldScript();
                     f1.x = tmpX;
                     f1.y = tmpY--;
                     tmpFields.Add(f1);
                     FieldScript f2 = new FieldScript();
                     f2.x = tmpX++;
                     f2.y = tmpY--;
                     tmpFields.Add(f2);
                     FieldScript f3 = new FieldScript();
                     f3.x = tmpX--;
                     f3.y = tmpY;
                     tmpFields.Add(f3);
                     FieldScript f4 = new FieldScript();
                     f4.x = tmpX++;
                     f4.y = tmpY++;
                     tmpFields.Add(f4);
                     FieldScript f5 = new FieldScript();
                     f5.x = tmpX;
                     f5.y = tmpY++;
                     tmpFields.Add(f5);
                     FieldScript f6 = new FieldScript();
                     f6.x = tmpX--;
                     f6.y = tmpY;
                     tmpFields.Add(f6);
                 }
                 foreach (var elem in tmpFields)
                 {
                     FieldScript tmpField2 = FindField(elem.x, elem.y);
                     if (tmpField2.hero != null)
                     {
                         UnitScript def2          = tmpField2.InstHero.GetComponent <UnitScript>();
                         float      finallyAttack = of.UnitAction(def2) - def2.armor;
                         if (finallyAttack > 0)
                         {
                             def2.life -= finallyAttack;
                         }
                     }
                 }
             }
             SelectedField     = null;
             somethingSelected = false;
             ChangeRound();
             print(def.life);
         }
         else
         {
             if ((Mathf.Abs(tmpField.x - of.x) <= of.movementSpeed) && (Mathf.Abs(tmpField.y - of.y) <= of.movementSpeed))
             {
                 tmpField.hero = SelectedField.hero;
                 SaveHero(tmpField);
                 Destroy(SelectedField.InstHero);
                 SelectedField     = null;
                 somethingSelected = false;
                 ChangeRound();
             }
         }
     }
     else
     {
         FieldScript tmpField = FindField(x, y);
         UnitScript  of       = tmpField.InstHero.GetComponent <UnitScript>();
         if (of.Player != Round)
         {
             print("round: " + Round + "player: " + of.Player);
             return;
         }
         SelectedField     = tmpField;
         somethingSelected = true;
         //print(somethingSelected);
     }
 }
コード例 #10
0
 // Start is called before the first frame update
 void Awake()
 {
     field = GameObject.Find("Field").GetComponent <FieldScript>();
 }
コード例 #11
0
 private void GetDependencies()
 {
     fieldScript = GameObject.FindObjectOfType <FieldScript>();
 }
コード例 #12
0
ファイル: Piece.cs プロジェクト: Spierek/SpyChess
    // MOVEMENT
    private bool CheckMovement(FieldScript field)
    {
        if (field == GameController.Instance.board.GetField(currentPos))
            return false;

        if (field.occupied && field.currentPiece.owner == owner)
            return false;

        if (!CheckMovementRules(field.pos))
            return false;

        return true;
    }
コード例 #13
0
ファイル: Form1.cs プロジェクト: Segachief/GodoFlevel
        // Method that chunks an flevel then re-assembles it
        void bw_Compress(object sender, DoWorkEventArgs e)
        {
            ExtractArgs ea = (ExtractArgs)e.Argument;

            using (var fs = new FileStream(ea.Input, FileMode.Open))
            {
                var           df     = FF7Files.LoadLGP(fs, ea.Input);
                int           file   = 0;
                List <byte[]> chunks = new List <byte[]>();
                //string flev = Path.Combine(ea.Output, Path.GetFileName("flevel.lgp"));
                string flev = Directory.GetCurrentDirectory() + "\\PC\\Output File\\flevel.lgp";

                // Apply ToC and CRC to the new flevel
                byte[] addStart = new byte[23301];
                fs.Position = 0;
                fs.Read(addStart, 0, addStart.Length);
                using (var appendStart = new FileStream(flev, FileMode.Append))
                {
                    appendStart.Write(addStart, 0, addStart.Length);
                    appendStart.Close();
                }

                int   tocPointer  = 36;     // Holds pointer location for where to write new offset for ToC
                ulong fieldOffset = 0x5B05; // Holds offset value to write into tocPointer
                int   fieldCount  = 0;      // Counts fields
                foreach (var item in df.Items)
                {
                    (sender as BackgroundWorker).ReportProgress(100 * file++ / df.Items.Count);
                    // This route is for field files
                    if (Path.GetExtension(item.Name).Length == 0 &&
                        item.Name != "maplist"
                        // These files 'shrink' when included; seem functional but excluded for now
                        && item.Name != "blackbgb" &&
                        item.Name != "frcyo" &&
                        item.Name != "fship_4" &&
                        item.Name != "las0_8" &&
                        item.Name != "las2_1" &&
                        item.Name != "uutai1"
                        )
                    {
                        byte[] ff = new byte[item.Length - 24];
                        fs.Position = item.Start + 24;
                        fs.Read(ff, 0, ff.Length);
                        chunks = FieldFile.Unchunk(ff);

                        // >>>>
                        // Can adjust the uncompressed chunks here if need be before they go to recompression
                        // Randomisation tasks should be called here, triggered based on section #
                        // >>>>

                        // If using consistent allocation of models, then that logic should be done somewhere here so
                        // that all fields passing through have access to the newly assigned HRC strings and can pass
                        // them through to the rando logic.

                        // Sends Field Script chunk of field to be randomised
                        if (chkItems.Checked)
                        {
                            chunks[0] = FieldScript.ChangeItemsMateria(chunks[0], item.Name);
                        }

                        // Sends Model Loader chunk of field to be randomised
                        if (chkModels.Checked)
                        {
                            chunks[2] = ModelLoader.SwapFieldModels(chunks[2]);
                        }

                        // Recompresses the chunks into a field
                        var field = FieldFile.Chunk(chunks, item.Name);

                        // Skip the first ToC offset as this won't change
                        if (fieldCount != 0)
                        {
                            // Adds field length to pointer so we know where next section starts
                            tocPointer += 27;
                            byte[] byteOffset = EndianMethods.GetLittleEndianConvert(fieldOffset);
                            using (Stream stream = File.Open(flev, FileMode.Open))
                            {
                                stream.Position = tocPointer;
                                stream.Write(byteOffset, 0, 4);
                            }
                        }

                        // Takes the size of the chunked field; used to determine next offset for ToC
                        fieldOffset += (ulong)field.Length;
                        fieldCount++;

                        // Writes it into the new flevel
                        using (var stream = new FileStream(flev, FileMode.Append))
                        {
                            stream.Write(field, 0, field.Length);
                        }
                    }
                    // This route is for non-field files
                    else
                    {
                        byte[] field = new byte[item.Length];
                        fs.Position = item.Start;
                        fs.Read(field, 0, field.Length);

                        // Adds field length to pointer so we know where next section starts
                        tocPointer += 27;
                        byte[] byteOffset = EndianMethods.GetLittleEndianConvert(fieldOffset);
                        using (Stream stream = File.Open(flev, FileMode.Open))
                        {
                            stream.Position = tocPointer;
                            stream.Write(byteOffset, 0, 4);
                        }
                        // Takes the size of the misc file
                        fieldOffset += (ulong)field.Length;
                        fieldCount++;

                        // Writes it into the new flevel
                        using (var stream = new FileStream(flev, FileMode.Append))
                        {
                            stream.Write(field, 0, field.Length);
                        }
                    }
                }
                // Adds the final terminating string to the flevel
                byte[] terminate = new byte[] { 0x46, 0x49, 0x4E, 0x41, 0x4C, 0x20, 0x46, 0x41, 0x4E, 0x54, 0x41, 0x53, 0x59, 0x37 };
                using (var finalStream = new FileStream(flev, FileMode.Append))
                {
                    finalStream.Write(terminate, 0, terminate.Length);
                }
            }
        }
コード例 #14
0
ファイル: AttackField.cs プロジェクト: Spierek/SpyChess
 public override void Set(Piece piece, FieldScript field)
 {
     base.Set(piece, field);
     targetPiece = field.currentPiece;
 }
コード例 #15
0
 // Use this for initialization
 void Start()
 {
     fieldScript = GameManager.GetComponent <FieldScript>();
 }