void Start() { mover = GetComponent <RayMover>(); mover.CheckForSupport(Vector2.down, false); controls = new MovementActions(); animator = GetComponent <Animator>(); sprite = GetComponent <SpriteRenderer>(); mover.UpdateFromBoxCollider(); CalculateControls(); }
public string Upgrade(int upgradeType) { if (PlayerInfo.Position != PlayerInfo.HouseLocation) { return(MovementActions.MoveTo(GameMap, PlayerInfo.HouseLocation - PlayerInfo.Position)); } else { return(AIHelper.CreateUpgradeAction((UpgradeType)upgradeType)); } }
/// <summary> /// Move to rock and if close enough, collect /// </summary> public static string MoveToRock(Map map) { Point position = new Point(2000, 2000); if (PlayerInfo.CarriedResources == PlayerInfo.CarryingCapacity) { return(MovementActions.MoveTo(map, PlayerInfo.HouseLocation - PlayerInfo.Position)); } else { foreach (Tile t in map.GetVisibleTiles()) { if (t.TileType == TileContent.Resource) { if (Math.Pow(t.Position.X - PlayerInfo.Position.X, 2) + Math.Pow(t.Position.Y - PlayerInfo.Position.Y, 2) < Math.Pow(position.X - PlayerInfo.Position.X, 2) + Math.Pow(position.Y - PlayerInfo.Position.Y, 2)) { position = new Point(t.Position.X, t.Position.Y); } } } double distance = Math.Sqrt(Math.Pow((position.X - PlayerInfo.Position.X), 2) + (Math.Pow((position.Y - PlayerInfo.Position.Y), 2))); if (distance > 1) { if (map.GetTileAt(PlayerInfo.Position.X + 1, PlayerInfo.Position.Y) == TileContent.Wall) { return(AIHelper.CreateMeleeAttackAction(new Point(1, 0))); } else if (map.GetTileAt(PlayerInfo.Position.X - 1, PlayerInfo.Position.Y) == TileContent.Wall) { return(AIHelper.CreateMeleeAttackAction(new Point(-1, 0))); } else if (map.GetTileAt(PlayerInfo.Position.X, PlayerInfo.Position.Y + 1) == TileContent.Wall) { return(AIHelper.CreateMeleeAttackAction(new Point(0, 1))); } else if (map.GetTileAt(PlayerInfo.Position.X, PlayerInfo.Position.Y - 1) == TileContent.Wall) { return(AIHelper.CreateMeleeAttackAction(new Point(0, -1))); } return(MovementActions.MoveTo(map, position - PlayerInfo.Position)); } else { return(AIHelper.CreateCollectAction(position - PlayerInfo.Position)); } } }
public string Rechercher() { if (GameMap.GetTileAt(PlayerInfo.Position.X + 1, PlayerInfo.Position.Y) == TileContent.Wall) { return(AIHelper.CreateMeleeAttackAction(new Point(1, 0))); } else if (GameMap.GetTileAt(PlayerInfo.Position.X - 1, PlayerInfo.Position.Y) == TileContent.Wall) { return(AIHelper.CreateMeleeAttackAction(new Point(-1, 0))); } else if (GameMap.GetTileAt(PlayerInfo.Position.X, PlayerInfo.Position.Y + 1) == TileContent.Wall) { return(AIHelper.CreateMeleeAttackAction(new Point(0, 1))); } else if (GameMap.GetTileAt(PlayerInfo.Position.X, PlayerInfo.Position.Y - 1) == TileContent.Wall) { return(AIHelper.CreateMeleeAttackAction(new Point(0, -1))); } return(MovementActions.MoveTo(GameMap, PlayerInfo.HouseLocation - PlayerInfo.Position)); }
private void Start() { movementController = GetComponent <MovementController>(); movement = new MovementActions(); movement.Forward.AddDefaultBinding(InputControlType.LeftStickY); movement.Strafe.AddDefaultBinding(InputControlType.LeftStickX); movement.RotatePosX.AddDefaultBinding(InputControlType.RightStickX); movement.RotatePosY.AddDefaultBinding(InputControlType.RightStickY); ringLauncherController = GetComponent <RingLauncher>(); ringLauncherAction = new LauncherActions(); ringLauncherAction.ActivateRingIntake.AddDefaultBinding(InputControlType.Action1); ringLauncherAction.LaunchRing.AddDefaultBinding(InputControlType.LeftTrigger); ringLauncherAction.IncreaseFlywheelPower.AddDefaultBinding(InputControlType.DPadUp); ringLauncherAction.DecreaseFlywheelPower.AddDefaultBinding(InputControlType.DPadDown); wobblerAction = new WobblerArmActions(); wobblerController = GetComponentInChildren <WobblerAttachmentController>(); wobblerAction.LiftArm.AddDefaultBinding(InputControlType.RightBumper); wobblerAction.LowerArm.AddDefaultBinding(InputControlType.LeftBumper); }
// Use this for initialization void Awake() { simpleActions = GetComponent <SimpleActions> (); mvtActions = GetComponent <MovementActions> (); }