00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 using System;
00018 using System.Collections.Generic;
00019 using System.Text;
00020 using DXGfxLib;
00021 using Microsoft.DirectX;
00022
00023 namespace Game
00024 {
00025 public class Boat : WorldEntity, ICanMove
00026 {
00027 private Action currentAction = new Action();
00028
00029 public Action CurrentAction
00030 {
00031 get { return currentAction; }
00032 set
00033 {
00034 currentAction = value;
00035 if (mission != null)
00036 {
00037 currentAction.completed += new ActionCompletedHandler(mission.ActionComplete);
00038 }
00039 }
00040 }
00041
00042 public float speed = 0;
00043
00044 public Mission mission;
00045
00046 public void UpdateAI(double appTime, float elapsedTime)
00047 {
00048 if (!currentAction.iamdone)
00049 {
00050 currentAction.Update(appTime, elapsedTime);
00051 }
00052 }
00053
00054 public void Move(Vector3 direction, float elapsedTime)
00055 {
00056
00057 float terrainHeigth = World.GetGlobalInstance().TerrainHeigth(sceneObj.Position.X + 0.1f * direction.X,
00058 sceneObj.Position.Z + 0.1f * direction.Z);
00059
00060 if (terrainHeigth < -0.1f)
00061 {
00062
00063 direction.Y = 0;
00064
00065 Matrix trans = Matrix.Translation(Vector3.Multiply(direction, speed * elapsedTime));
00066 sceneObj.ApplyWorldTransform(trans);
00067 }
00068 }
00069 }
00070 }