Example #1
0
    public static List <ActionPointData> Parse(string path)
    {
        using (BinaryReader b = new BinaryReader(File.Open(path, FileMode.Open)))
        {
            var res = new List <ActionPointData>();
            while (b.BaseStream.Position != b.BaseStream.Length)
            {
                var m = new ActionPointData
                {
                    LocationCode  = b.ReadInt32().SwapBytes(),
                    ToLevel       = b.ReadByte(),
                    ToX           = b.ReadByte(),
                    ToY           = b.ReadByte(),
                    PercentChance = b.ReadByte()
                };
                for (int i = 0; i < 8; i++)
                {
                    m.CommandCodes[i] = b.ReadInt16().SwapBytes();
                }
                for (int i = 0; i < 8; i++)
                {
                    m.ArgumentCodes[i] = b.ReadInt16().SwapBytes();
                }

                res.Add(m);
            }

            return(res);
        }
    }
Example #2
0
        public override void TreeTraversal(ADecisionNode p_sourceNode)
        {
            //TODO -> Store executed attacks in a vector, then the consumer read the vector and transforms them in EntityActions.
            ActionPoint     l_sourceEntityActionPoint = EntityComponent.get_component <ActionPoint>(SourceEntity);
            ActionPointData l_virtualActionPointData  = new ActionPointData()
            {
                InitialActionPoints = l_sourceEntityActionPoint.ActionPointData.InitialActionPoints,
                CurrentActionPoints = l_sourceEntityActionPoint.ActionPointData.InitialActionPoints
            };

            while (l_virtualActionPointData.CurrentActionPoints >= Attack.AttackData.APCost)
            {
                ActionPointData.add(ref l_virtualActionPointData, -1 * Attack.AttackData.APCost);
                DamageDone      += Attack.AttackData.Damage;
                NumberOfAttacks += 1;
            }
        }
Example #3
0
    public static void LoadScenario()
    {
        var path = Application.dataPath + "/Resources/Scenarios/City Of Bywater/";

        GameData.LevelData         = LevelData.Parse(path + "Data LD");
        GameData.ScenarioData      = ScenarioData.Parse(path + "City of Bywater");
        GameData.SolidSpecial      = Solid.Parse(path + "Data Solids");
        GameData.ActionPoints      = ActionPointData.Parse(path + "Data DD");
        GameData.ActionPointsExtra = ActionPointData.Parse(path + "Data ED3");
        GameData.Strings           = String.Parse(path + "Data SD2");
        GameData.SimpleEncounter   = SimpleEncounterData.Parse(path + "Data ED");
        GameData.ExtraCodes        = ExtraCode.Parse(path + "Data EDCD");
        GameData.LevelMetaData     = LevelMetaData.Parse(path + "Data RD");

        GameData.x     = GameData.ScenarioData.StartX;
        GameData.y     = GameData.ScenarioData.StartY;
        GameData.level = GameData.ScenarioData.StartLevel;
    }
Example #4
0
    public void TriggerComponentTest_navigationNodeMove()
    {
        // Initializing trigger Entity
        Entity l_testTriggerEntity = Entity.alloc();

        l_testTriggerEntity.EntityGameWorld = EntityGameWorld.build(TransformComponent.alloc());

        EntityComponent.add_component(l_testTriggerEntity, NavigationEngineTestTriggerComponent.alloc());
        EntityComponent.add_component(l_testTriggerEntity, Locomotion.alloc(new LocomotionData()
        {
            Speed = float.MaxValue * 0.1f
        }));

        // We warp the l_testTriggeredEntity to a random NavigationNode
        EventQueue.enqueueEvent(
            TestEventQueue,
            NavigationNodeWarpEntityEvent.alloc(
                l_testTriggerEntity,
                NavigationGraphAlgorithm.pickRandomNode(NavigationGraphContainer.UniqueNavigationGraph)
                )
            );

        EventQueue.iterate(TestEventQueue);

        // We create the Entity that will be involved in the trigger
        Entity l_entity = Entity.alloc();

        l_entity.EntityGameWorld = EntityGameWorld.build(TransformComponent.alloc());

        EntityComponent.add_component(l_entity, Locomotion.alloc(new LocomotionData()
        {
            Speed = float.MaxValue * 0.1f
        }));

        ActionPointData l_actionPointdata = new ActionPointData()
        {
            InitialActionPoints = 999f, CurrentActionPoints = 999f
        };

        EntityComponent.add_component(l_entity, ActionPoint.alloc(ref l_actionPointdata));

        var l_entityNavigationNodeEnumerator =
            NavigationGraphAlgorithm.getReachableNeighborNavigationNodes(NavigationGraphContainer.UniqueNavigationGraph, l_testTriggerEntity.CurrentNavigationNode, NavigationGraphFlag.CURRENT).GetEnumerator();

        l_entityNavigationNodeEnumerator.MoveNext();

        EventQueue.enqueueEvent(
            TestEventQueue,
            NavigationNodeWarpEntityEvent.alloc(
                l_entity,
                l_entityNavigationNodeEnumerator.Current
                )
            );


        NavigationNodeMoveEvent l_navigationNodeMoveEvent = NavigationNodeMoveEvent.alloc(l_entity, l_testTriggerEntity.CurrentNavigationNode);

        EventQueue.enqueueEvent(
            TestEventQueue,
            l_navigationNodeMoveEvent
            );

        while (!l_navigationNodeMoveEvent.IsCompleted())
        {
            LocomotionSystemV2Container.Tick(1.0f);
            EventQueue.iterate(TestEventQueue);
        }

        NavigationEngineTestTriggerComponent l_triggerComponent = EntityComponent.get_component <NavigationEngineTestTriggerComponent>(l_testTriggerEntity);

        Assert.IsTrue(l_triggerComponent.IsTriggered);
        Assert.IsTrue(l_triggerComponent.TriggeredEntity == l_entity);
    }