コード例 #1
0
    public IEnumerator ExecuteMove(AIMoveType moveType)
    {
        if (moveType == AIMoveType.towards)
        {
            rb.drag = enemy.moveSpeed * .001f;
            rb.AddForce(direction.normalized * enemy.moveSpeed);
        }
        if (moveType == AIMoveType.inchTowrads)
        {
            rb.drag = enemy.moveSpeed * .001f * 9f;
            rb.AddForce(direction.normalized * enemy.moveSpeed);
            yield return(new WaitForSeconds(enemy.idleMinMax.y));
        }
        if (moveType == AIMoveType.sineTowrads)
        {
            // Ehhh this is not working correctly

            /* Example from Sebastian --------------------
             *
             * Vector3 target = targetPosition + targetDirectionFromPlayer *.7 + Vector3.up * .5f;
             * transform.position = Vector3.SmoothDamp(transform.position,target,ref smoothV, speed);
             *
             * float XOffset = Mathf.Sin(Time.time*random.xSpeed);
             * float YOffset = (Mathf.Sin(Time.time*random.ySpeed )+1 * random.yDegree;
             * Vector3 offset = new Vector3(offsetX,offsetY) * (1.1f-offsetPercent);
             * Transform.Translate(deltaOffset,Space.self);
             *
             */
            rb.drag = enemy.moveSpeed * .001f;
            float   sine    = Mathf.Sin(Time.time * Random.Range(1, 5)) * transform.position.z;
            Vector3 sineDir = new Vector3(direction.x + sine, direction.y, direction.z + sine);
            rb.AddForce(sineDir * enemy.moveSpeed);
        }
        yield return(null);

        SetMovement();
    }
コード例 #2
0
ファイル: Movement.cs プロジェクト: KroneckerX/WCell
		public Movement(Unit owner, AIMoveType moveType)
		{
			m_owner = owner;
			m_moveType = moveType;
			m_MayMove = true;
		}
コード例 #3
0
 public override void Start()
 {
     this.m_owner.Movement.MoveType = this.MoveType;
     this.MoveToNext();
 }
コード例 #4
0
 public AIFollowPathAction(Unit owner, Path path = null, AIMoveType moveType = AIMoveType.Walk)
     : base(owner)
 {
     this.Path     = path;
     this.MoveType = moveType;
 }
コード例 #5
0
		public AIFollowPathAction(Unit owner, Path path = null, AIMoveType moveType = AIMoveType.Walk)
			: base(owner)
		{
			Path = path;
			MoveType = moveType;
		}
コード例 #6
0
 public Movement(Unit owner, AIMoveType moveType)
 {
     m_owner    = owner;
     m_moveType = moveType;
     m_MayMove  = true;
 }