コード例 #1
0
 /// <summary>
 /// Initializes values upon awake
 /// </summary>
 /// <param name="owner"> The sate machine used by the script</param>
 public override void Initialize(StateMachine owner)
 {
     this.owner = (CowSM)owner;
     OwnerPhysics.SetAirResistance(0.95f);
     FollowSprite.SetActive(false);
     PatrolSprite.SetActive(false);
 }
コード例 #2
0
 /// <summary>
 /// Sets values upon initialization
 /// </summary>
 /// <param name="owner"></param>
 public override void Initialize(StateMachine owner)
 {
     this.owner = (GiantSM)owner;
     OwnerPhysics.SetAirResistance(0.95f);
     PatrolSprite.SetActive(false);
     AttackSprite.SetActive(false);
     ChaseSprite.SetActive(false);
     //patrolPointCenter = owner.transform.GetComponentInParent<Transform>().transform.position; //giants kommer ha en parent som är mitten av dess patrolpoint
 }
コード例 #3
0
 /// <summary>
 /// Controlls the time interval and % chance for the game object to activate the ScareCow event.
 /// </summary>
 public override void Update()
 {
     OwnerPhysics.SetVelocity(AIagent.velocity);
     ShoutTimer += Time.deltaTime;
     if (ShoutTimer >= ShoutCooldown && Random.Range(1, 10) > 5)
     {
         ScareCowEventInfo scei = new ScareCowEventInfo
         {
             scarySoundLocation = Position.position
         };
         EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.ScareCow, scei);
         ShoutTimer = 0;
     }
 }
コード例 #4
0
ファイル: GnomeBaseState.cs プロジェクト: Flargy/Portfolio
 /// <summary>
 /// Assigns values to variables on initialization.
 /// </summary>
 /// <param name="owner"> Reference to the object the <see cref="GnomeStateMachine"/> is attached to</param>
 public override void Initialize(StateMachine owner)
 {
     this.owner = (GnomeStateMachine)owner;
     OwnerPhysics.SetAirResistance(0.95f);
     AIagent.speed = Speed;
 }
コード例 #5
0
ファイル: WolfBaseState.cs プロジェクト: Flargy/Portfolio
    private void InheritVelocity(Transform collideObject, ref Vector3 normalForce)
    {
        PhysicsComponent physics = collideObject.GetComponent <PhysicsComponent>();

        if (physics == null)
        {
            return;
        }
        normalForce = normalForce.normalized * (normalForce.magnitude + Vector3.Project(physics.GetVelocity(), normalForce.normalized).magnitude);
        Vector3 forceInDirection = Vector3.ProjectOnPlane(AIagent.velocity - physics.GetVelocity(), normalForce.normalized);
        Vector3 friction         = -forceInDirection.normalized * normalForce.magnitude * OwnerPhysics.GetStaticFriction();

        if (friction.magnitude > forceInDirection.magnitude)
        {
            friction = friction.normalized * forceInDirection.magnitude;
        }
        AIagent.velocity += friction;
    }
コード例 #6
0
ファイル: WolfBaseState.cs プロジェクト: Flargy/Portfolio
 public override void Initialize(StateMachine owner)
 {
     this.owner = (WolfSM)owner;
     OwnerPhysics.SetAirResistance(0.95f);
 }
コード例 #7
0
ファイル: WolfBaseState.cs プロジェクト: Flargy/Portfolio
 protected void setVelocity()
 {
     OwnerPhysics.SetVelocity(AIagent.velocity);
 }