void MoveToPosition(TargetPos targetPos) { if (targetPos.targetVector != null) { npcStateMashine.ChangeState(new MoveToBehaviour(this.navAgent, this.gameObject, targetPos, 1f, anim, StartSearching)); } }
public override void WriteTo(pb::CodedOutputStream output) { int size = SerializedSize(); if (HasType) { output.WriteInt32(1, Type); } if (HasScenceId) { output.WriteInt32(2, ScenceId); } { output.WriteTag((int)3, pb::WireFormat.WireType.LengthDelimited); output.WriteRawVarint32((uint)TargetPos.SerializedSize()); TargetPos.WriteTo(output); } if (HasLangueId) { output.WriteInt32(4, LangueId); } if (HasResult) { output.WriteInt32(5, Result); } if (HasMissionId) { output.WriteInt32(6, MissionId); } }
public MoveToBehaviour(NavMeshAgent navAgent, GameObject owner, TargetPos target, float stoppingDistance, Animator anim, System.Action searchForNew) { this.navAgent = navAgent; this.anim = anim; this.owner = owner; this.targetObj = target.targetObj; this.targetVec = target.targetVector; this.stoppingDistance = stoppingDistance; this.searchForNew = searchForNew; }
bool IsInRange() { if (LockType == SkillLockType.NoLock) { return(true); } float sqrDistance = TargetPos.SqrDistanceWith(transform.position); return(sqrDistance >= SkillMinRange * SkillMinRange && sqrDistance <= SkillMaxRange * SkillMaxRange); }
//获取目标位置坐标 Vector2 GetTargetPoint(TargetPos pos) { if (pos == TargetPos.OriginUnit) { return effect.originUnit.pos; } else if (pos == TargetPos.TargetPoint) { return effect.targetPoint; } return default; }
void Start() { targetpos_object = GameObject.Find("target"); targetpos_script = targetpos_object.GetComponent <TargetPos>(); root1_object = GameObject.Find("root1"); root1_script = root1_object.GetComponent <root1>(); Goal_object = GameObject.Find("goal"); Goal_script = Goal_object.GetComponent <Goal>(); Floor_object = GameObject.Find("floor1"); Floor_script = Floor_object.GetComponent <Floor>(); }
//end merged public override bool IsInitialized() { if (HasTargetPos) { if (!TargetPos.IsInitialized()) { return(false); } } return(true); }
public void Execute() { if (timer < Time.time) { timer = Time.time + wanderTimer; Vector3 newPos = RandomNavSphere(this.owner.transform.position, wanderRadius, -1); // setNewTargetPos(newPos); //Send Movetarget to the walking behaviour TargetPos target = new TargetPos(newPos); setNewTargetPosCallback(target); } }
//for initialization void Start() { targetpos_object = GameObject.Find("target"); targetpos_script = targetpos_object.GetComponent <TargetPos>(); targetpos2_object = GameObject.Find("target2"); targetpos2_script = targetpos2_object.GetComponent <TargetPos2>(); root2_object = GameObject.Find("root2"); root2_script = root2_object.GetComponent <root2>(); Floor_object = GameObject.Find("floor1"); Floor_script = Floor_object.GetComponent <Floor>(); Goal_object = GameObject.Find("goal"); Goal_script = Goal_object.GetComponent <Goal>(); cube_object = GameObject.Find("Cube"); cube_script = cube_object.GetComponent <cube>(); x = 10; }
public void SearchResultFound(SearchResults searchResult) { List <Collider> foundSerchedResult = searchResult.allHitObjsWithReqTag; if (searchResult.closestObjWithTag != null) { //Move to state TargetPos newSearchTarget = new TargetPos(searchResult.closestObjWithTag); npcStateMashine.ChangeState(new MoveToBehaviour(this.navAgent, this.gameObject, newSearchTarget, 1f, anim, StartSearching)); } else { Debug.Log("Entered: Wander stage"); //Wander state npcStateMashine.ChangeState(new WanderBehaviour(this.gameObject, this.navAgent, this.wanderRadius, this.wanderTimer, MoveToPosition)); } }
public virtual void SetTargetTransform(Transform targetTransform) { target = targetTransform; if (!TargetPos.Equals(Vector3.zero)) { TargetPos = Vector3.zero; if (path != null) {//Release the previous path path.Release(this); path = null; SearchPath(); } } TargetPos = Vector3.zero; LookDir = Vector3.zero; }
void Attract(Attractor objToAttract) { //----------------SELF MADE NICELY NICE STUFF//------ actual = TargetPos.getPos(); if (delta >= 0.033f + 0.02 * 14) { delta = 0.033f + 0.02f * 14; } if (delta <= 0) { delta = 0; } position = new Vec3(fx, fy, fz); // Planeta petit dir = sunPos - position; dist = Vec3.Distance(sunPos, position); inter = new Vec3(fx - fx / 3, fy - fy / 3, fz - fz / 3); float f = (G * bigMass * mass) / Mathf.Pow(dist, 2); Vec3 gravity = Vec3.Normalize(dir) * f; velocity.x = velocity.x + delta / 20 * gravity.x; velocity.y = velocity.y + delta / 20 * gravity.y; velocity.z = velocity.z + delta / 20 * gravity.z; // position = position + velocity * Time.deltaTime; fx = fx + velocity.x * delta; fy = fy + velocity.y * delta; fz = fz + velocity.z * delta; q.y += 1 * Mathf.Rad2Deg; transform.position = new Vector3(position.x, position.y, position.z); transform.rotation = new Quaternion(q.x, q.y, q.z, q.w); pos = new Vector3(position.x, position.y, position.z); vforce = new Vector3(fx, fy, fz); Vector3 intt = new Vector3(inter.x, inter.y, inter.z); }
void Start() { targetpos_object = GameObject.Find("target"); targetpos_script = targetpos_object.GetComponent <TargetPos>(); targetpos2_object = GameObject.Find("target2"); targetpos2_script = targetpos2_object.GetComponent <TargetPos2>(); targetpos3_object = GameObject.Find("target3"); targetpos3_script = targetpos3_object.GetComponent <TargetPos3>(); root1_object = GameObject.Find("root1"); root1_script = root1_object.GetComponent <root1>(); root2_object = GameObject.Find("root2"); root2_script = root2_object.GetComponent <root2>(); goal_object = GameObject.Find("goal"); goal_script = goal_object.GetComponent <Goal>(); goal2_object = GameObject.Find("goal2"); goal2_script = goal2_object.GetComponent <Goal2>(); goal3_object = GameObject.Find("goal3"); goal3_script = goal3_object.GetComponent <Goal3>(); hanoi(3, 'A', 'B', 'C'); }
public ActuatorState SetFrom(IActuatorState other) { if (other != null) { TargetPos = other.TargetPos; TargetPosStr = other.TargetPosStr; TargetPositionInPercent = other.TargetPositionInPercent; PosState = other.PosState; PosStateStr = other.PosStateStr; PositionInPercent = other.PositionInPercent; } else { TargetPos = ActuatorPosition.None; TargetPosStr = TargetPos.ToString(); TargetPositionInPercent = 0.0; PosState = ActuatorPosition.Undefined; PosStateStr = TargetPos.ToString(); PositionInPercent = 0.0; } return(this); }
public override int SerializedSize() { int size = memoizedSerializedSize; if (size != -1) { return(size); } size = 0; if (HasType) { size += pb::CodedOutputStream.ComputeInt32Size(1, Type); } if (HasScenceId) { size += pb::CodedOutputStream.ComputeInt32Size(2, ScenceId); } { int subsize = TargetPos.SerializedSize(); size += pb::CodedOutputStream.ComputeTagSize((int)3) + pb::CodedOutputStream.ComputeRawVarint32Size((uint)subsize) + subsize; } if (HasLangueId) { size += pb::CodedOutputStream.ComputeInt32Size(4, LangueId); } if (HasResult) { size += pb::CodedOutputStream.ComputeInt32Size(5, Result); } if (HasMissionId) { size += pb::CodedOutputStream.ComputeInt32Size(6, MissionId); } memoizedSerializedSize = size; return(size); }