public void Initialize(CreatureAgent attachedAgent, Creature creature, Rigidbody attachedBody) { currentConstraints = attachedBody.constraints; CurrentState = MovementState.UNINITIALIZED; if (flightDirection == Direction.Y) { MaxForce = attachedAgent.maxForce.y; } else if (flightDirection == Direction.Z) { MaxForce = attachedAgent.maxForce.z; } else if (flightDirection == Direction.X) { MaxForce = attachedAgent.maxForce.x; } // Amount of force needed to hold the objects weight // if (flightDirection == Direction.Y) { MinForce = attachedAgent.minimumForceToHover; } else { MinForce = -MaxForce; } cf = creature.GetComponent <ConstantForce>(); startupRunningFor = 0; InitiateStartupSequence(); }
public EngineMovementVariables(CreatureAgent agent, Direction flightDirection, Dictionary <MiscVariables.AgentMiscVariables, float> miscVariables) : base(Vector3.zero, PartMovesWith.NA) { this.miscVariables = miscVariables; this.flightDirection = flightDirection; }
private void Initialize(string name, Area area) { base.initialize(name); this.currentArea = area; taskManager = new TaskManager(this); inventory = new Inventory(this); if (baseSpecies == BASE_SPECIES.Gnat) { species = new Species('m', "Gnat", true, BASE_SPECIES.Gnat, CONSUMPTION_TYPE.OMNIVORE, this); } else if (baseSpecies == BASE_SPECIES.Gagk) { species = new Species('n', baseSpecies.ToString(), true, BASE_SPECIES.Gagk, CONSUMPTION_TYPE.HERBIVORE, this); } creaturePhysicalStats = CreatureConstants.PhysicalStatsInitialize(species.getBaseSpecies(), this); agent = new CreatureAgent(this); audioSource = GetComponent <AudioSource>(); currentState = CREATURE_STATE.IDLE; creaturePhysicalStats.Initialize(species.getBaseSpecies()); agent.Initialize(species.getBaseSpecies()); miscVariables = MiscVariables.GetCreatureMiscVariables(this); memberOfTribe = null; knownGridSectorsVisited = new Dictionary <GridSector, bool>(); lastObserved = Random.Range(0, Time.time); observeEvery = 2.5f; initialized = true; }
protected Dictionary <MiscVariables.AgentMiscVariables, float> miscVariables; // Misc Constants public Part(CreaturePart creaturePart, Transform transform, float updateEvery) { this.PartType = creaturePart; this.PartTransform = transform; this.UpdateEvery = updateEvery; this.parentCreature = transform.GetComponentInParent <Creature>(); this.attachedAgent = parentCreature.GetCreatureAgent(); miscVariables = MiscVariables.GetAgentMiscVariables(parentCreature); audioClip = CreatureConstants.GetCreaturePartAudioClip(parentCreature.GetBaseSpecies(), creaturePart); Enabled = true; }
public static void CreatureAgentInitialize(BASE_SPECIES baseSpecies, CreatureAgent agent) { if (baseSpecies == BASE_SPECIES.Gnat) { agent.GetRigidBody().constraints = RigidbodyConstraints.None; agent.SetTurnSpeed(.3f); agent.SetSustainHeight(5); agent.SetMaxAngularVel(10); agent.SetMaxVelocityMagnitude(20); agent.SetCruisingSpeed(new Vector3(2, 1, 15)); // Maximum force of the constant force component // agent.maxForce.y = 15; agent.maxForce.z = 8; agent.maxForce.x = 4; // Amount of force needed to hold the objects weight // agent.SetMinimumForceToHover(8); agent.SetSlowDownModifier(1); agent.GetRigidBody().maxAngularVelocity = 5; agent.SetExploreRadiusModifier(200); agent.SetGrabType(CreatureGrabType.TractorBeam); BuildCreatureParts(baseSpecies, agent); } else if (baseSpecies == BASE_SPECIES.Gagk) { agent.SetTurnSpeed(1f); agent.SetSustainHeight(1); agent.SetMaxAngularVel(15); agent.SetMaxVelocityMagnitude(10); agent.SetCruisingSpeed(new Vector3(0, 0, 5)); // Maximum force of the constant force component // agent.maxForce.y = 0; agent.maxForce.z = 5; agent.maxForce.x = 0; // Amount of force needed to hold the objects weight // agent.SetMinimumForceToHover(0); agent.SetSlowDownModifier(15); agent.SetExploreRadiusModifier(200); BuildCreatureParts(baseSpecies, agent); } }
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); } }