Example #1
0
 public override IAnimation GetAnimation(RobotState state)
 {
     if (m_turnDirection == TurnDirection.Left)
     {
         if (m_initialLookDirection.HasValue)
         {
             if (m_initialLookDirection.Value == TurnDirection.Left)
             {
                 return(state.Robot.GetAnim("u_turn_left_from_look_left"));
             }
             else
             {
                 return(state.Robot.GetAnim("u_turn_left_from_look_right"));
             }
         }
         else
         {
             return(state.Robot.GetAnim("u_turn_left"));
         }
     }
     else
     {
         if (m_initialLookDirection.HasValue)
         {
             if (m_initialLookDirection.Value == TurnDirection.Left)
             {
                 return(state.Robot.GetAnim("u_turn_right_from_look_left"));
             }
             else
             {
                 return(state.Robot.GetAnim("u_turn_right_from_look_right"));
             }
         }
         else
         {
             return(state.Robot.GetAnim("u_turn_right"));
         }
     }
 }
Example #2
0
        public void GetLightInfo(RobotState state, out Vector3 o_position, out Vector3 o_colour)
        {
            var pos  = GetPosition(state);
            var anim = GetAnimation(state);

            if (anim != null)
            {
                bool    visible;
                Matrix4 transform;
                Vector2 uvOffset;
                Vector2 uvScale;
                Vector4 colour;
                float   cameraFOV;
                anim.Animate("Light", GetAnimTime(state), out visible, out transform, out uvOffset, out uvScale, out colour, out cameraFOV);
                o_position = pos + transform.Row3.Xyz;
                o_colour   = visible ? (colour.Xyz * colour.W) : Vector3.Zero;
            }
            else
            {
                o_position = pos;
                o_colour   = Vector3.One;
            }
        }
Example #3
0
 public override TileCoordinates GetDestination(RobotState state)
 {
     return(base.GetDestination(state).Move(Direction.Down, 2));
 }
Example #4
0
 public override RobotState Init(RobotState state)
 {
     state.Robot.PlaySound("beam_down");
     return(base.Init(state));
 }
Example #5
0
 public override IAnimation GetAnimation(RobotState state)
 {
     return(state.Robot.GetAnim("teleport_in"));
 }
 public override float GetAnimTime(RobotState state)
 {
     return(0.0f);
 }
        public override float GetAnimTime(RobotState state)
        {
            float timer = state.Level.TimeMachine.Time - state.TimeStamp;

            return(timer / DURATION);
        }
Example #8
0
 public override TileCoordinates GetDestination(RobotState state)
 {
     return(state.Position.Move(m_direction.GetX(), state.WalkIncline, m_direction.GetZ()));
 }
Example #9
0
 public override IAnimation GetAnimation(RobotState state)
 {
     return(state.Robot.GetAnim("at_goal"));
 }
Example #10
0
 public virtual RobotState Update(RobotState state, float dt)
 {
     return(state);
 }
Example #11
0
        private static RobotAction NextAction(RobotState state, bool allowTeleport = false, bool allowTurntable = false, bool ignoreMovingObjects = false)
        {
            var level    = state.Level;
            var position = state.Position;
            var below    = position.Below();
            var dir      = state.Direction;

            var currentTile = level.Tiles[position];
            var belowTile   = level.Tiles[below];

            // Try drowning
            if (belowTile.IsLiquid(level, below))
            {
                return(RobotActions.Drown);
            }

            // Try falling
            if (belowTile.CanEnterOnTop(level, below))
            {
                return(RobotActions.Fall);
            }

            // Try sitting at goal
            if (currentTile.IsGoal(level, position))
            {
                var colour = ((GoalTileBehaviour)currentTile.GetBehaviour(level, position)).Colour;
                if (colour == state.Robot.Colour)
                {
                    return(RobotActions.Goal);
                }
            }

            // Try teleporting
            if (allowTeleport && belowTile.IsTelepad(level, below))
            {
                var basePos     = belowTile.GetBase(level, below);
                var baseTile    = level.Tiles[basePos];
                var destination = ((TelepadTileBehaviour)baseTile.GetBehaviour(level, basePos)).GetDestination(level, basePos);
                if (destination.HasValue)
                {
                    return(RobotActions.TeleportOut);
                }
            }

            // Try conveying
            if (belowTile.IsConveyor(level, below))
            {
                var conveyor          = ((Conveyor)belowTile.GetEntity(level, below));
                var conveyorDirection = belowTile.GetDirection(level, below);
                if (conveyor.CurrentMode == ConveyorMode.Forwards)
                {
                    var conveyDirection = conveyorDirection;
                    if (CanEnter(state.Robot, position.Move(conveyDirection), conveyDirection, false))
                    {
                        return(RobotActions.GetConvey(conveyDirection));
                    }
                }
                else if (conveyor.CurrentMode == ConveyorMode.Reverse)
                {
                    var conveyDirection = conveyorDirection.Opposite();
                    if (CanEnter(state.Robot, position.Move(conveyDirection), conveyDirection, false))
                    {
                        return(RobotActions.GetConvey(conveyDirection));
                    }
                }
            }

            // Try turntabling
            if (allowTurntable && currentTile.IsTurntable(level, position))
            {
                var turn = ((TurntableTileBehaviour)currentTile.GetBehaviour(level, position)).TurnDirection;
                switch (turn)
                {
                case TurnDirection.Left:
                {
                    return(RobotActions.TurntableLeft);
                }

                case TurnDirection.Right:
                {
                    return(RobotActions.TurntableRight);
                }
                }
            }

            // Try moving
            if (!state.Robot.Immobile)
            {
                if (CanEnter(state.Robot, position.Move(dir), dir, ignoreMovingObjects))
                {
                    // Walk forward
                    int           incline         = GetWalkIncline(state.Robot, state.Position, state.Direction);
                    var           nextPos         = position.Move(dir.GetX(), incline, dir.GetZ());
                    var           nextAction      = NextAction(state.With(action: RobotActions.WalkLookForward, position: nextPos), allowTeleport: true, allowTurntable: true, ignoreMovingObjects: true);
                    TurnDirection?previousLookDir = null;
                    if (state.Action is RobotWalkAction)
                    {
                        previousLookDir = ((RobotWalkAction)state.Action).LookDirection;
                    }
                    if (nextAction is RobotTurnAction)
                    {
                        var turnAction = (RobotTurnAction)nextAction;
                        return(RobotActions.GetWalk(previousLookDir, turnAction.Direction));
                    }
                    else if (nextAction is RobotUTurnAction)
                    {
                        var turnAction = (RobotUTurnAction)nextAction;
                        return(RobotActions.GetWalk(previousLookDir, turnAction.Direction));
                    }
                    else
                    {
                        return(RobotActions.GetWalk(previousLookDir, null));
                    }
                }
                else
                {
                    // Turn
                    TurnDirection?lookDir = null;
                    if (state.Action is RobotWalkAction)
                    {
                        lookDir = ((RobotWalkAction)state.Action).LookDirection;
                    }

                    bool uTurn;
                    var  turn = GetTurnDirection(state.Robot, position, dir, state.TurnPreference, out uTurn, false);
                    if (uTurn)
                    {
                        return(RobotActions.GetUTurn(turn, lookDir));
                    }
                    else
                    {
                        return(RobotActions.GetTurn(turn, lookDir));
                    }
                }
            }

            // Wait
            return(RobotActions.Wait);
        }
Example #12
0
 public virtual RobotState Init(RobotState state)
 {
     return(state.With(action: this, timeStamp: state.Robot.Level.TimeMachine.Time));
 }
 public override IAnimation GetAnimation(RobotState state)
 {
     return(state.Robot.GetAnim("drowned"));
 }
 public override RobotState Init(RobotState state)
 {
     return(base.Init(state));
 }
Example #15
0
        public override float GetAnimTime(RobotState state)
        {
            float offset = (float)(state.RandomSeed % 255) / 64.0f;

            return(state.Level.TimeMachine.RealTime + offset);
        }
Example #16
0
 public override RobotState Update(RobotState state, float dt)
 {
     return(state);
 }
Example #17
0
 public float GetYaw(RobotState state)
 {
     return(state.Direction.ToYaw());
 }
Example #18
0
 public override float GetAnimTime(RobotState state)
 {
     return(state.Level.TimeMachine.Time - state.TimeStamp);
 }
Example #19
0
        protected static RobotState PickNextAction(RobotState state, bool allowTeleport = false, bool allowTurntable = false)
        {
            var action = NextAction(state, allowTeleport, allowTurntable, ignoreMovingObjects: false);

            return(action.Init(state));
        }
 public override IAnimation GetAnimation(RobotState state)
 {
     return(state.Robot.GetAnim("beam_down"));
 }
Example #21
0
 public virtual IAnimation GetAnimation(RobotState state)
 {
     return(state.Robot.GetAnim("idle"));
 }
 public override IAnimation GetAnimation(RobotState state)
 {
     return(LuaAnimation.Get("animation/invisible.anim.lua"));
 }
Example #23
0
 public virtual float GetLightBrightness(RobotState state)
 {
     return(1.0f);
 }
Example #24
0
 public override RobotState Init(RobotState state)
 {
     state.Robot.PlaySound("teleport_in");
     return(base.Init(state));
 }
Example #25
0
 public virtual TileCoordinates GetDestination(RobotState state)
 {
     return(state.Position);
 }
 public override TileCoordinates GetDestination(RobotState state)
 {
     return(state.Position);
 }
Example #27
0
 public override TileCoordinates GetDestination(RobotState data)
 {
     return(data.Position.Below());
 }
Example #28
0
 public override RobotState Init(RobotState state)
 {
     state.Robot.PlaySound("turn");
     state.Robot.PlaySound("idle_loop", true);
     return(base.Init(state));
 }
Example #29
0
 public override RobotState Init(RobotState state)
 {
     state.Robot.EmitOnDrown();
     return(base.Init(state));
 }