// Use this for initialization
 public override AivoTreeStatus Act(float timeTick, Hammy owner)
 {
     owner.rigid.velocity = Vector3.zero;             // shouldnt be here but...
     Debug.Log(BoolName + " " + ActivateBool);
     owner.anim.SetBool(BoolName, ActivateBool);
     return(AivoTreeStatus.Success);
 }
        public override AivoTreeStatus Act(float timeTick, Hammy owner)
        {
            owner.patrolRoute.Clear();
            owner.patrolIndex = 0;
            int     roomAmount     = owner.waypointNavigator.dungeon.RoomCount;
            Vector3 playerPos      = owner.playerTransform.value.position;
            int     startRoomIndex = owner.waypointNavigator.dungeon.GetRoomIndex((int)owner.mTransform.position.x, (int)owner.mTransform.position.z);

            owner.patrolRoute.Add(startRoomIndex);
            float max_dist = float.MinValue;
            int   max_ind  = -1;

            for (int i = 0; i < roomAmount; i++)
            {
                Vector2 roomCenter = owner.waypointNavigator.dungeon.Rooms[i].rect.center;
                float   distance   = Vector3.Distance(
                    new Vector3(roomCenter.x, 0, roomCenter.y), playerPos);
                if (prevInd != i)
                {
                    max_ind  = distance > max_dist ? i : max_ind;
                    max_dist = distance > max_dist ? distance : max_dist;
                }
            }
            prevInd = max_ind;
            owner.patrolRoute.Add(max_ind);
            owner.waypointNavigator.StartNavigation(max_ind);
            return(AivoTreeStatus.Success);
        }
Ejemplo n.º 3
0
        public override AivoTreeStatus Act(float timeTick, Hammy owner)
        {
            if (owner.HammerBaseTransform.position.y > 0.1 && owner.InAir())
            {
                return(AivoTree.AivoTreeStatus.Running);
            }
            if (owner.targetInstance == null)
            {
                return(AivoTree.AivoTreeStatus.Failure);
            }
            Vector3 direction = owner.playerTransform.value.position - owner.targetInstance.transform.position;

            direction.y = 0;
            double distance = direction.magnitude;

            if (distance < owner.radius.value)
            {
                Debug.Log(distance);
                sis.value.OnHit(owner, owner.damage.value, direction.normalized * force, owner.transform.position);
            }
            owner.SpawnExplosionAtPos(owner.targetInstance.transform.position + Vector3.up * 0.1f);
            owner.PlaySlam();
            owner.DestroyTarget();
            owner.rigid.velocity = Vector3.zero;
            return(AivoTree.AivoTreeStatus.Success);
        }
Ejemplo n.º 4
0
        public override bool CheckCondition(Hammy owner)
        {
            Vector3 position       = owner.mTransform.position;
            Vector3 playerPosition = owner.playerTransform.value.position;
            Vector3 distanceVector = playerPosition - position;

            distanceVector.y = 0;
            return(distanceVector.magnitude < Range);
        }
Ejemplo n.º 5
0
        public override AivoTreeStatus Act(float timeTick, Hammy owner)
        {
            Vector3 position = owner.playerTransform.value.position;

            position.y = 0;
            owner.SpawnTargetAtPos(position);
            owner.PlayUnburrow();             //unburrow sound
            return(AivoTree.AivoTreeStatus.Success);
        }
Ejemplo n.º 6
0
        //float timer = 0;

        public override AivoTree.AivoTreeStatus Act(float timeTick, Hammy owner)
        {
            owner.waitTimer += Time.deltaTime;
            if (owner.waitTimer > SecondsToWait)
            {
                owner.waitTimer = 0;
                return(AivoTree.AivoTreeStatus.Success);
            }
            return(AivoTree.AivoTreeStatus.Running);
        }
 public override bool CheckCondition(Hammy owner)
 {
     foreach (HammyCondition cond in HammyConditions)
     {
         if (!cond.CheckCondition(owner))
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 8
0
        public override AivoTreeStatus Act(float timeTick, Hammy owner)
        {
            owner.patrolRoute.Clear();
            owner.patrolIndex = 0;
            int roomAmount = owner.waypointNavigator.dungeon.RoomCount;
            int randomRoom = Random.Range(0, roomAmount);

            owner.patrolRoute.Add(randomRoom);
            owner.waypointNavigator.StartNavigation(randomRoom);
            return(AivoTreeStatus.Success);
        }
Ejemplo n.º 9
0
        public override AivoTreeStatus Act(float timeTick, Hammy owner)
        {
            owner.rigid.velocity = Vector3.zero;
            Vector3 direction = owner.playerTransform.value.position - owner.mTransform.position;

            direction.y = 0;
            owner.mTransform.rotation = Quaternion.Slerp(owner.mTransform.rotation,
                                                         Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z)), turnSpeed * Time.deltaTime);
            Vector3 motion = owner.mTransform.forward * owner.moveSpeed.value;

            owner.rigid.velocity = motion;
            return(AivoTree.AivoTreeStatus.Running);
        }
Ejemplo n.º 10
0
        public override bool CheckCondition(Hammy owner)
        {
            Vector3    position       = owner.FinTransform.position;
            Vector3    playerPosition = owner.playerTransform.value.position;
            Vector3    direction      = playerPosition - position;
            RaycastHit raycastHit;
            LayerMask  mapAndPlayer = LayerMask.NameToLayer("Player") | LayerMask.NameToLayer("Map");
            Ray        ray          = new Ray(position, direction);

            if (Physics.Raycast(ray, out raycastHit, Mathf.Infinity, ~mapAndPlayer))
            {
                return(raycastHit.collider.tag == "Player");
            }
            return(false);
        }
        public override AivoTreeStatus Act(float timeTick, Hammy owner)
        {
            owner.patrolRoute.Clear();
            owner.patrolIndex = 0;

            Vector3 position = owner.transform.position;
            Dungeon dungeon  = owner.waypointNavigator.dungeon;

            int startRoomIndex = dungeon.GetRoomIndex((int)owner.mTransform.position.x, (int)owner.mTransform.position.z);

            owner.patrolRoute.Add(startRoomIndex);
            // random for now.. need to create a proper connected route.
            for (int i = 0; i < PatrolLength; i++)
            {
                Room randomRoom = dungeon.GetRandomRoom();
                owner.patrolRoute.Add(dungeon.GetRoomIndex(randomRoom));
            }
            owner.waypointNavigator.StartNavigation(startRoomIndex);
            return(AivoTreeStatus.Success);
        }
Ejemplo n.º 12
0
        public override bool CheckCondition(Hammy owner)
        {
            Vector3    position       = owner.FinTransform.position + Vector3.up * 0.2f;
            Vector3    playerPosition = owner.playerTransform.value.position + Vector3.up * 0.2f;
            Vector3    direction      = playerPosition - position;
            RaycastHit raycastHit;
            LayerMask  mapAndPlayer = LayerMask.NameToLayer("Player") | LayerMask.NameToLayer("Map");
            Ray        ray          = new Ray(position, direction);

            Debug.DrawLine(position, playerPosition, Color.green);

            if (Mathf.Abs(Mathf.Acos(Vector3.Dot(direction.normalized, owner.mTransform.forward)) * Mathf.Rad2Deg) < 20)
            {
                if (Physics.Raycast(ray, out raycastHit, Mathf.Infinity, ~mapAndPlayer))
                {
                    Debug.DrawLine(position, playerPosition, Color.green);
                    return(raycastHit.collider.tag == "Player");
                }
            }
            return(false);
        }
        public override AivoTreeStatus Act(float timeTick, Hammy owner)
        {
            owner.patrolRoute.Clear();
            owner.patrolIndex = 0;

            Vector3 position = owner.transform.position;
            Dungeon dungeon  = owner.waypointNavigator.dungeon;

            int startRoomIndex = dungeon.GetClosestRoomIndex((int)position.x, (int)position.y);

            Debug.Log(startRoomIndex);
            owner.patrolRoute.Add(startRoomIndex);
            // random for now.. need to create a proper connected route.
            for (int i = 0; i < PatrolLength; i++)
            {
                int roomAmount = dungeon.RoomCount;
                int randomRoom = Random.Range(0, roomAmount);
                owner.patrolRoute.Add(randomRoom);
            }
            owner.waypointNavigator.StartNavigation(startRoomIndex);
            return(AivoTreeStatus.Success);
        }
        public override AivoTreeStatus Act(float timeTick, Hammy owner)
        {
            if (owner.targetInstance == null)
            {
                return(AivoTree.AivoTreeStatus.Running);                //hack
            }
            owner.rigid.velocity = Vector3.zero;
            Vector3 direction = owner.targetInstance.transform.position - owner.HammerBaseTransform.position;

            direction.y = 0;
            Quaternion quatDirection = Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z));

            if (Quaternion.Angle(owner.mTransform.rotation, quatDirection) < 10)
            {
                owner.mTransform.rotation = Quaternion.Slerp(owner.mTransform.rotation, quatDirection, 1 * Time.deltaTime);
            }
            Vector3 motion = Vector3.ClampMagnitude(direction, 1) * 5;

            // Vector3 motion = owner.mTransform.forward * owner.moveSpeed.value;
            owner.rigid.velocity = motion;
            return(AivoTree.AivoTreeStatus.Running);
        }
        public override AivoTreeStatus Act(float timeTick, Hammy owner)
        {
            owner.rigid.velocity = Vector3.zero;
            if (owner.waypointNavigator.PathFinished)
            {
                int nextRoomIndex = owner.GetNextPatrolRoomIndex();
                if (nextRoomIndex == -1)
                {
                    return(AivoTreeStatus.Success);
                }
                owner.waypointNavigator.StartNavigation(nextRoomIndex);
            }

            Vector3 direction = owner.waypointNavigator.DirectionToWaypoint;

            owner.mTransform.rotation = Quaternion.Slerp(owner.mTransform.rotation,
                                                         Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z)), turnSpeed * owner.delta);

            Vector3 motion = owner.mTransform.forward * moveSpeed * owner.delta;

            owner.rigid.velocity = motion;
            return(AivoTree.AivoTreeStatus.Running);
        }
Ejemplo n.º 16
0
 public abstract AivoTree.AivoTreeStatus Act(float timeTick, Hammy owner);
Ejemplo n.º 17
0
 public override bool CheckCondition(Hammy owner)
 {
     return(Value);
 }
Ejemplo n.º 18
0
 public override void Execute(Hammy owner)
 {
     owner.waypointNavigator.SetWaypointGraph();
 }
Ejemplo n.º 19
0
        public override AivoTreeStatus Act(float timeTick, Hammy owner)
        {
            /*
             * if ((lastPosition - owner.mTransform.position).magnitude < 0.02) { // Fail Safe
             *      time += Time.deltaTime;
             *      if (time > 3) {
             *              Debug.Log("Reset Path");
             *              int roomIndex = Random.Range(0, owner.waypointNavigator.dungeon.RoomCount);
             *              owner.waypointNavigator.StartNavigation(roomIndex);
             *      }
             * } else {
             *      time = 0;
             * }
             */
            lastPosition         = owner.mTransform.position;
            owner.rigid.velocity = Vector3.zero;
            if (owner.waypointNavigator.PathFinished)
            {
                owner.wasHit = false;
                int nextRoomIndex = owner.GetNextPatrolRoomIndex();
                if (nextRoomIndex == -1)
                {
                    return(AivoTreeStatus.Success);
                }
                owner.waypointNavigator.StartNavigation(nextRoomIndex);
            }

            Vector3 direction = owner.waypointNavigator.DirectionToWaypoint;

            direction.y = 0.4f - owner.mTransform.position.y;
            float curMoveSpeed = (fleeSpeedBoost ? owner.fleeSpeed.value : owner.moveSpeed.value);

            //Sharp Turns

            /*if (Vector3.Angle(direction.normalized, owner.mTransform.forward) > 90)
             * {
             *      curMoveSpeed *= 0.8f;
             *      //Debug.Log("Sharp Angle!");
             *      owner.mTransform.rotation = Quaternion.Slerp(owner.mTransform.rotation,
             *              Quaternion.LookRotation(direction), 5 * Time.deltaTime);
             * }
             * else */if (Vector3.Angle(direction.normalized, owner.mTransform.forward) > 0.075)
            {
                curMoveSpeed *= 0.8f;
                Vector3 rot = direction - owner.mTransform.forward;
                // owner.forward *= rot * turnSpeed * Time.deltaTime;
                owner.transform.rotation =
                    Quaternion.RotateTowards(owner.transform.rotation, Quaternion.LookRotation(direction),
                                             turnSpeed.value * (fleeSpeedBoost ? 4 : 1));
                // owner.mTransform.rotation = Quaternion.Lerp(owner.mTransform.rotation,
                //  Quaternion.LookRotation(direction), turnSpeed * Time.deltaTime);
            }

            if (!fleeSpeedBoost)
            {
                if (owner.wasHit)
                {
                    owner.wasHit = false;
                    owner.waypointNavigator.StartNavigation(sisTransform.value.position);
                }
            }

            Vector3 motion = owner.mTransform.forward * curMoveSpeed;

            owner.rigid.velocity = motion;
            return(AivoTree.AivoTreeStatus.Running);
        }
Ejemplo n.º 20
0
 public override AivoTreeStatus Act(float timeTick, Hammy owner)
 {
     condition.Value = SetValue;
     return(AivoTree.AivoTreeStatus.Success);
 }
 public override void Execute(Hammy owner)
 {
     action.Execute(owner);
 }
 public override bool CheckCondition(Hammy owner)
 {
     return(!NegatedCondition.CheckCondition(owner));
 }