Ejemplo n.º 1
0
        protected override void OnExecuteEvent(VEntity entity)
        {
            MovementEvent       moveEvent           = VEntityComponentSystemManager.GetVComponent <MovementEvent>(entity);
            PositionTrackSystem positionTrackSystem = ecsManager.GetSystem <PositionTrackSystem>();

            // check to make sure that the square is unoccupied
            bool isUnoccupied = true;

            foreach (VEntity v in positionTrackSystem.GetAtCoord(moveEvent.targetCoord))
            {
                if (VEntityComponentSystemManager.HasVComponent <MovementBlockComponent>(v))
                {
                    isUnoccupied = false;
                }
            }

            if (isUnoccupied)
            {
                PositionComponent movedPosition = ecsManager.GetVComponent <PositionComponent>(moveEvent.sourceId);
                Coord             prevPosition  = movedPosition.position;
                movedPosition.position = moveEvent.targetCoord;
                positionTrackSystem.Update(movedPosition.position, moveEvent.sourceId);

                ecsManager.QueueAnimationEvent(ecsManager.CreateEntity("MoveAnim", component: new MovementAnimationEvent {
                    entityToMove = moveEvent.sourceId,
                    from         = prevPosition,
                    to           = moveEvent.targetCoord
                }));
            }
        }
Ejemplo n.º 2
0
        protected override void OnBeforeEvent(VEntity eventEntity)
        {
            MovementEvent         movement     = eventEntity.GetVComponent <MovementEvent>();
            VEntity               movedEntity  = ecsManager.GetVEntityById(movement.sourceId);
            QueuedActionComponent queuedAction = movedEntity.GetVComponent <QueuedActionComponent>();

            if (queuedAction != null)
            {
                Debug.Log("removing old highlights");
                // update the view with animation event
                Coord[] targetedCoords = Coord.ResolveRelativeCoords(queuedAction.relativeTargetedCoords, movedEntity.GetVComponent <PositionComponent>().position);

                ecsManager.QueueAnimationEvent("highlight", component: new GenericImmediateAnimationEvent {
                    a = (passedEcsManager) => {
                        passedEcsManager.GetAnimationSystem <HighlightDisplaySystem>().Remove(null, new List <string> {
                            movedEntity.id
                        });
                    }
                });
            }
        }
Ejemplo n.º 3
0
        protected override void OnAfterEvent(VEntity eventEntity)
        {
            MovementEvent         movement     = eventEntity.GetVComponent <MovementEvent>();
            VEntity               movedEntity  = ecsManager.GetVEntityById(movement.sourceId);
            QueuedActionComponent queuedAction = movedEntity.GetVComponent <QueuedActionComponent>();

            if (queuedAction != null)
            {
                // update the view with animation event
                Coord[] targetedCoords = Coord.ResolveRelativeCoords(queuedAction.relativeTargetedCoords, movedEntity.GetVComponent <PositionComponent>().position);

                ecsManager.QueueAnimationEvent("highlight", component: new GenericImmediateAnimationEvent {
                    a = (passedEcsManager) => {
                        passedEcsManager.GetAnimationSystem <HighlightDisplaySystem>().CreateHighlightsWithTags(targetedCoords, new List <string> {
                            "EnemyAttack",
                            movedEntity.id
                        }, passedEcsManager.GetAnimationSystem <HighlightDisplaySystem>().redColor);
                    }
                });
            }
        }