public Actor(string filename) { ActorManager.Instance().AddActor(this); mPosition = Vector2.Zero; mFilename = filename; }
public void Reset() { Unload(); ActorManager.Instance().Clear(); Load(mFilename); }
private bool CollisionOtherBox(Vector2 pos) { var actors = ActorManager.Instance().GetActors(); foreach (var actor in actors) { if (!(actor is Box) || actor == this) //Box以外は興味ない { continue; } if (Actor.IsCollision(pos, actor)) { return(true); } } return(false); }
public void PreviousPosition(ref Vector2 pos) { if (mFootprint.Count <= 1) { return; } pos = mFootprint[mFootprint.Count - 2]; mFootprint.RemoveAt(mFootprint.Count - 1); var actors = ActorManager.Instance().GetActors(); foreach (var actor in actors) { if (actor is Box) { var b = ((Box)actor).GetPrevious(); actor.SetPosition(b[b.Count - 2]); b.RemoveAt(b.Count - 1); } } mWalkCount -= 1; }
private void ResetState(ref Vector2 pPos) { int px, py; px = (int)(pPos.X + 5) / 64; py = (int)(pPos.Y + 5) / 64; pPos = new Vector2(px, py) * 64; if (!mIsBoxStageOrOtherBoxCollide) { mWalkCount += 1; mFootprint.Add(pPos); var actors = ActorManager.Instance().GetActors(); foreach (var actor in actors) { if (actor is Box) { ((Box)actor).SetPrevious(actor.GetPosition()); } } } mIsBoxStageOrOtherBoxCollide = false; if (mHitBox != null) { int bx, by; bx = (int)(mHitBox.GetPosition().X + 5) / 64; by = (int)(mHitBox.GetPosition().Y + 5) / 64; Vector2 bp = new Vector2(bx, by) * 64; mHitBox.SetPosition(bp); } mState = MoveState.NONE; mHitBox = null; GameDevice.Instance().GetSound().StoppedSE(); }
private bool MoveOption(Vector2 inVec) { var actors = ActorManager.Instance().GetActors(); foreach (var actor in actors) { if (!(actor is Box)) //Box以外は興味ない { continue; } Vector2 p = inVec; if (mState == MoveState.LEFT) { if (inVec.X <= 5f) { p.X = Screen.PLAY_WIDTH - GridSize.GRID_SIZE; } else { p.X = inVec.X - GridSize.GRID_SIZE; } } else if (mState == MoveState.RIGHT) { if (inVec.X >= Screen.PLAY_WIDTH - GridSize.GRID_SIZE - 5) { p.X = 0f; } else { p.X = inVec.X + GridSize.GRID_SIZE; } } else if (mState == MoveState.UP) { if (inVec.Y <= 5f) { p.Y = Screen.HEIGHT - GridSize.GRID_SIZE; } else { p.Y = inVec.Y - GridSize.GRID_SIZE; } } else if (mState == MoveState.DOWN) { if (inVec.Y >= Screen.HEIGHT - GridSize.GRID_SIZE - 5f) { p.Y = 0f; } else { p.Y = inVec.Y + GridSize.GRID_SIZE; } } if (Actor.IsCollision(p, actor)) { ((Box)actor).BranchUpdate(mState, ref mIsBoxStageOrOtherBoxCollide); if (mIsBoxStageOrOtherBoxCollide) { return(false); } mHitBox = actor; break; } } return(true); }