public void Land()
 {
     for (int count = 0; count < allParts.Count; count++)
     {
         if (allParts[count] is EnginePart)
         {
             EnginePart currentPart = (EnginePart)allParts[count];
             // TODO Landing
         }
     }
     landing = true;
 }
 // Called from Creature Object //
 public void OnCollisionEnter(Collision collision)
 {
     if (!touchingBodies.Contains(collision.gameObject.transform))
     {
         touchingBodies.Add(collision.gameObject.transform);
     }
     for (int count = 0; count < allParts.Count; count++)
     {
         if (!(allParts[count] is EnginePart))
         {
             continue;
         }
         EnginePart currentPart = (EnginePart)allParts[count];
         currentPart.OnCollisionEnter(collision);
     }
 }
 // Called from Creature Object //
 public void OnCollisionExit(Collision collision)
 {
     if (touchingBodies.Contains(collision.gameObject.transform))
     {
         touchingBodies.Remove(collision.gameObject.transform);
         //Debug.LogWarning("Body not touching anymore - " + collision.gameObject.name);
     }
     for (int count = 0; count < allParts.Count; count++)
     {
         if (!(allParts[count] is EnginePart))
         {
             continue;
         }
         EnginePart currentPart = (EnginePart)allParts[count];
         currentPart.OnCollisionExit(collision);
     }
 }
 public void Initialize(BASE_SPECIES baseSpecies)
 {
     rigidbody = creature.GetComponent <Rigidbody>();
     CreatureConstants.CreatureAgentInitialize(baseSpecies, this);
     if (rigidbody == null)
     {
         rigidbody = creature.GetComponentInParent <Rigidbody>();
         if (rigidbody == null)
         {
             rigidbody = creature.GetComponentInChildren <Rigidbody>();
             if (rigidbody == null)
             {
                 Debug.LogError("Can't find rigid body on " + creature.thingName);
             }
         }
     }
     rigidbody.constraints = RigidbodyConstraints.None;
     _transform            = rigidbody.transform;
     if (baseSpecies == BASE_SPECIES.Gnat)
     {
         locomotionType = CreatureLocomotionType.Flight;
     }
     else if (baseSpecies == BASE_SPECIES.Gagk)
     {
         locomotionType = CreatureLocomotionType.StandardForwardBack;
     }
     foreach (Part part in allParts)
     {
         if (part is EnginePart)
         {
             EnginePart movePart = (EnginePart)part;
             movePart.InitializeMovementPart();
         }
     }
     ignoreIncomingCollisions = false;
     initialized = true;
 }
Exemple #5
0
        public static void BuildCreatureParts(BASE_SPECIES baseSpecies, CreatureAgent agent)
        {
            Creature    creature  = agent.creature;
            Rigidbody   rigidbody = agent.GetRigidBody();
            List <Part> allParts  = new List <Part>();

            if (baseSpecies == BASE_SPECIES.Gnat)
            {
                // Body with constant force //
                EnginePart bodyFlight = new EnginePart
                                            (CreaturePart.BODY, creature.transform.GetChild(0), CreatureLocomotionType.Flight, .2f);

                // Body with Rotation turning //
                TurnPart bodyTurning = new TurnPartRotation
                                           (CreaturePart.BODY, creature.transform.GetChild(0), CreatureTurnType.Rotate, .2f);

                // Backward Propeller //
                AnimationPart zPropeller = new AnimationPart(CreaturePart.ENGINE_Z, creature.transform.GetChild(1),
                                                             CreatureAnimationMovementType.Rotation, .05f, Vector3.up, 10, new ActionStep.Actions[]
                                                             { ActionStep.Actions.Add, ActionStep.Actions.Land, ActionStep.Actions.MoveTo, ActionStep.Actions.Wait, ActionStep.Actions.Sleep },
                                                             PartMovesWith.ConstantForceZ, PartAnimationType.Movement, true);

                // Y Propellers //
                AnimationPart yPropeller = new AnimationPart(CreaturePart.ENGINE_Y, creature.transform.GetChild(3),
                                                             CreatureAnimationMovementType.Rotation, .05f, Vector3.up, 10, new ActionStep.Actions[]
                                                             { ActionStep.Actions.Add, ActionStep.Actions.Land, ActionStep.Actions.MoveTo, ActionStep.Actions.Wait, ActionStep.Actions.Sleep },
                                                             PartMovesWith.ConstantForceY, PartAnimationType.Movement, true);
                AnimationPart yPropeller2 = new AnimationPart(CreaturePart.ENGINE_Y, creature.transform.GetChild(4),
                                                              CreatureAnimationMovementType.Rotation, .05f, Vector3.up, 10, new ActionStep.Actions[]
                                                              { ActionStep.Actions.Add, ActionStep.Actions.Land, ActionStep.Actions.MoveTo, ActionStep.Actions.Wait, ActionStep.Actions.Sleep },
                                                              PartMovesWith.ConstantForceY, PartAnimationType.Movement, true);
                AnimationPart yPropeller3 = new AnimationPart(CreaturePart.ENGINE_Y, creature.transform.GetChild(5),
                                                              CreatureAnimationMovementType.Rotation, .05f, Vector3.up, 10, new ActionStep.Actions[]
                                                              { ActionStep.Actions.Add, ActionStep.Actions.Land, ActionStep.Actions.MoveTo, ActionStep.Actions.Wait, ActionStep.Actions.Sleep },
                                                              PartMovesWith.ConstantForceY, PartAnimationType.Movement, true);
                AnimationPart yPropeller4 = new AnimationPart(CreaturePart.ENGINE_Y, creature.transform.GetChild(6),
                                                              CreatureAnimationMovementType.Rotation, .05f, Vector3.up, 10, new ActionStep.Actions[]
                                                              { ActionStep.Actions.Add, ActionStep.Actions.Land, ActionStep.Actions.MoveTo, ActionStep.Actions.Wait, ActionStep.Actions.Sleep },
                                                              PartMovesWith.ConstantForceY, PartAnimationType.Movement, true);

                // Antigrav Shield //
                AntiGravityShieldPart shieldPart = new AntiGravityShieldPart(CreaturePart.SHIELD, creature.transform.GetChild(9),
                                                                             .2f, creature.GetCreatureAgent().GetRigidBody(), new ActionStep.Actions[] { ActionStep.Actions.Add,
                                                                                                                                                         ActionStep.Actions.Locate, ActionStep.Actions.None, ActionStep.Actions.Wait });
                AnimationPart antiGravShieldAnimation = new AnimationPart(CreaturePart.SHIELD, creature.transform.GetChild(7),
                                                                          CreatureAnimationMovementType.Rotation, .05f, Vector3.up, 10, new ActionStep.Actions[]
                                                                          { ActionStep.Actions.Add, ActionStep.Actions.MoveTo, ActionStep.Actions.Add, ActionStep.Actions.Eat
                                                                            , ActionStep.Actions.Locate, ActionStep.Actions.None, ActionStep.Actions.Wait },
                                                                          PartMovesWith.IsKinematic, PartAnimationType.Movement, false);

                // Tractor Beam //
                TractorBeamPart          tractorBeam      = new TractorBeamPart(creature.transform, .2f, 30);
                TractorBeamAnimationPart tractorAnimation = new TractorBeamAnimationPart(CreaturePart.TRACTORBEAM,
                                                                                         creature.transform.GetChild(8), .2f, Vector3.forward, .3f);

                allParts.Add(bodyFlight);
                allParts.Add(bodyTurning);
                allParts.Add(zPropeller);
                allParts.Add(yPropeller);
                allParts.Add(yPropeller2);
                allParts.Add(yPropeller3);
                allParts.Add(yPropeller4);
                allParts.Add(shieldPart);
                allParts.Add(antiGravShieldAnimation);
                allParts.Add(tractorBeam);
                allParts.Add(tractorAnimation);
                agent.SetCreatureTurnType(CreatureTurnType.Rotate);
                agent.setParts(allParts);
            }
            else if (baseSpecies == BASE_SPECIES.Gagk)
            {
                // Constant force for Z //
                EnginePart mainEngine = new EnginePart(CreaturePart.ENGINE_Z,
                                                       creature.transform.GetChild(0),
                                                       CreatureLocomotionType.StandardForwardBack, 1);
                TurnPart inchSpine = new TurnPartInching(CreaturePart.BODY,
                                                         creature.transform.GetChild(0),
                                                         CreatureTurnType.Inch, .5f, Direction.X,
                                                         creature.transform.GetChild(1));
                allParts.Add(mainEngine);
                allParts.Add(inchSpine);
                agent.SetCreatureTurnType(CreatureTurnType.Inch);
                agent.setParts(allParts);
            }
        }