コード例 #1
0
ファイル: Sea.cs プロジェクト: davidyu/Poisson
 public override void Render(GameTime gameTime, SpriteBatch batch, Camera cam)
 {
     batch.Draw(this.SpriteTexture, this.Pos,
         this.SpriteRect, Color.White,
         this.Orient, new Vector2(0f, 0f), 2.0f, SpriteEffects.None, this.depth);
     batch.Draw(this.SpriteTexture, this.Pos- cam.ScreenToWorld(new Vector2(this.SpriteRect.Width, 0.0f)),
        this.SpriteRect, Color.White,
        this.Orient, new Vector2(0f, 0f), 2.0f, SpriteEffects.None, this.depth);
 }
コード例 #2
0
ファイル: Sea.cs プロジェクト: davidyu/Poisson
        public override void Update(GameTime gameTime, List<Entity> entities, Entity player, Camera cam)
        {
            Vector2 tempPos = this.Pos;

            this.Pos += this.Vel;
            if (this.Pos.X > this.SpriteRect.Width*2) {
                tempPos.X -= this.SpriteRect.Width;
                this.Pos = tempPos;
            } else if (this.Pos.X < 0) {
                tempPos.X += this.SpriteRect.Width;
                this.Pos = tempPos;
            }
        }
コード例 #3
0
ファイル: Ship.cs プロジェクト: davidyu/Poisson
        public override void Render(GameTime gameTime, SpriteBatch batch, Camera cam)
        {
            this.hook.Render(gameTime, batch, cam);
            SpriteEffects spriteEffects = new SpriteEffects();

            if (!this.FacingLeft) {
                spriteEffects = SpriteEffects.FlipHorizontally;
            }
            else {
            }
            if (!FacingLeft) {
                spriteEffects = SpriteEffects.FlipHorizontally;
            } else {
            }

            Rectangle destRect = new Rectangle((int)this.Pos.X, (int)this.Pos.Y, (int)SpriteRect.Width, (int)SpriteRect.Height);
            batch.Draw(this.SpriteTexture, this.Pos,
                this.SpriteRect, Color.White,
                this.Orient, new Vector2(0f, 0f), 1.0f, spriteEffects, 0.4f);
        }
コード例 #4
0
ファイル: Fish.cs プロジェクト: davidyu/Poisson
 private void PollInput(Camera cam)
 {
     TouchCollection tc = TouchPanel.GetState();
     foreach (TouchLocation tl in tc) {
         if (tl.State == TouchLocationState.Moved || tl.State == TouchLocationState.Pressed) {
             Vector2 touchPos = cam.ScreenToWorld(tl.Position); //converted to camera pos
             SteerToward(touchPos, 0.1f);
             Thrust();
         }
     }
 }
コード例 #5
0
ファイル: Fish.cs プロジェクト: davidyu/Poisson
 private void FindNewTarget(Camera cam)
 {
     Random random = new Random();
     this.target = cam.ScreenToWorld(new Vector2((float)random.NextDouble() * 800.0f, (float)random.NextDouble() * 480.0f));
 }
コード例 #6
0
ファイル: Fish.cs プロジェクト: davidyu/Poisson
 private void Autonomous(Entity player, Camera cam)
 {
     Vector2 delta = player.Pos - Pos;
     if (this.State == EFishState.STEERING)
     {
         if (delta.Length() >= 400.0) {
             this.State = EFishState.SPONTANEOUS;
             FindNewTarget(cam);
         } else {
             SteerToward(player.Pos, 0.5f);
             Thrust();
         }
     }
     else if (this.State == EFishState.SPONTANEOUS)
     {
         Vector2 dprime = target - Pos;
         if (delta.Length() <= 300.0) {
             this.State = EFishState.STEERING;
         } else if (dprime.Length() <= 20.0) {
             FindNewTarget(cam);
         } else {
             SteerToward(target, 0.2f);
             Thrust();
         }
     }
 }
コード例 #7
0
ファイル: Fish.cs プロジェクト: davidyu/Poisson
        public override void Update(GameTime gameTime, List<Entity> entities, Entity player, Camera cam)
        {
            if (this.hooked || this.State == EFishState.DEAD)
                return;

            if (isHuman) {
                PollInput(cam);
            } else {
                Autonomous(player, cam);
            }

            this.Orient = (this.Orient + MathUtils.CIRCLE) % MathUtils.CIRCLE; //clamp to 0 < Orient < 2pi
            this.flipY = (this.Orient > MathUtils.QUARTER_CIRCLE && this.Orient < 3 * MathUtils.QUARTER_CIRCLE);
            this.AngVel *= ANG_FRICTION;
            this.Vel *= FRICTION;

            this.Orient += this.AngVel;
            if (this.Pos.Y < SEA_LEVEL)
                this.Vel += new Vector2(0f, 2f);
            this.Pos += this.Vel;
        }
コード例 #8
0
ファイル: Fish.cs プロジェクト: davidyu/Poisson
        public override void Render(GameTime gameTime, SpriteBatch batch, Camera cam)
        {
            this.effects = this.flipY ? SpriteEffects.FlipVertically : SpriteEffects.None;

            Rectangle destRect = new Rectangle((int)this.Pos.X, (int)this.Pos.Y, (int)SpriteRect.Width, (int)SpriteRect.Height);
            batch.Draw(this.SpriteTexture, this.Pos,
                this.SpriteRect, Color.White,
                this.Orient, new Vector2((float) SpriteRect.Width/2, SpriteRect.Height/2), 1.0f, this.effects, 0.0f);
            batch.Draw(this.rect, new Vector2(this.BoundingRect.X, this.BoundingRect.Y), Color.White);
        }
コード例 #9
0
ファイル: Entity.cs プロジェクト: davidyu/Poisson
 public virtual void Update(GameTime gameTime, List<Entity> entities, Entity player, Camera cam)
 {
 }
コード例 #10
0
ファイル: Entity.cs プロジェクト: davidyu/Poisson
 public virtual void Render(GameTime gameTime, SpriteBatch batch, Camera cam)
 {
 }
コード例 #11
0
ファイル: Ship.cs プロジェクト: davidyu/Poisson
        public override void Update(GameTime gameTime, List<Entity> entities, Entity player, Camera cam)
        {
            if (!this.FacingLeft) {
                this.hook.Pos = new Vector2((float)ROD_OFFSET_FLIP+this.Pos.X, this.hook.Pos.Y);
            }
            else {
                this.hook.Pos = new Vector2((float)ROD_OFFSET+this.Pos.X, this.hook.Pos.Y);
            }
            this.hook.Update(gameTime, entities, player, cam);

            switch (this.shipState) {
                case EShipState.SEEKING:
                    //this.Vel = new Vector2(1.0f, 0.0f);
                    break;
                case EShipState.WAITING:
                    break;
                case EShipState.HOOKING:
                    break;
            }

            if (shipState == EShipState.SEEKING) {
                if (Math.Abs(this.Pos.X - this.shipDestination.X) < 10.0)
                {
                    setShipToWait(gameTime);
                }
            }

            if ((shipState == EShipState.WAITING) && (gameTime.TotalGameTime.TotalMilliseconds >= this.timeToNextHook)) {
                setShipToSeek();
                //setShipToHook();
            }

            //if (this.Pos.X < 0.0f || this.Pos.X > 1300) { //turn around if hit edge
            //    this.Vel *= -1.0f;
            //    this.FacingLeft = !this.FacingLeft;
            //}

            if (!this.FacingLeft) {
                this.hook.Pos = new Vector2(ROD_OFFSET_FLIP + this.Pos.X, this.hook.Pos.Y);
            }
            else {
                this.hook.Pos = new Vector2(ROD_OFFSET + this.Pos.X, this.hook.Pos.Y);
            }
            //switch (this.hook.HookState) {
            //    case Hook.EHookState.MOVING:
            //        Vector2 pos = this.hook.Pos;
            //        pos.Y -= BORING_HOOK_VEL;
            //        this.hook.Pos = pos;
            //        if (pos.Y <= TOP_OF_ROD) {
            //            this.hook.HookState = Hook.EHookState.RETRACTED;
            //            setShipToSeek();
            //        }
            //        break;
            //    //case Hook.EHookState.DOWN:
            //    //    this.hookPos.Y += BORING_HOOK_VEL;
            //    //    if (this.hookPos.Y >= BOTTOM_OF_SCREEN)
            //    //        this.hookState = EHookState.UP;
            //    //    break;
            //    case Hook.EHookState.RETRACTED:
            //        break;
            //}

            this.Pos += this.Vel;
            //this.Vel *= FRICTION;
        }