public void ActionButton(LocomotionAction action) { if (this.ActionButtonInvoked != null) { this.ActionButtonInvoked(action); } }
private void OnActionButtonClicked(LocomotionAction action) { switch (action) { case LocomotionAction.Interact: break; case LocomotionAction.Action1: break; case LocomotionAction.Action2: break; case LocomotionAction.Action3: break; case LocomotionAction.Jump: break; case LocomotionAction.ChargeThrow: case LocomotionAction.LaunchThrow: case LocomotionAction.Torpedo: case LocomotionAction.SlideTrick: break; } }
public override void DoAction(LocomotionAction action, object userData = null) { switch (action) { case LocomotionAction.ChargeThrow: DefaultDoAction(action, userData); break; case LocomotionAction.LaunchThrow: DefaultDoAction(action, userData); break; case LocomotionAction.Interact: case LocomotionAction.Action1: case LocomotionAction.Action2: case LocomotionAction.Action3: DefaultDoAction(action, userData); break; case LocomotionAction.Jump: if (!Behaviour.IgnoreJumpRequests && !jumpRequest.Active) { jumpRequest.Set(); base.Broadcaster.BroadcastOnDoAction(action, userData); } break; case LocomotionAction.Torpedo: case LocomotionAction.SlideTrick: break; } }
public override void DoAction(LocomotionAction action, object userData = null) { switch (action) { case LocomotionAction.ChargeThrow: DefaultDoAction(action, userData); break; case LocomotionAction.LaunchThrow: DefaultDoAction(action, userData); break; case LocomotionAction.Interact: DefaultDoAction(action, userData); break; case LocomotionAction.Action1: case LocomotionAction.Action2: case LocomotionAction.Action3: DefaultDoAction(action, userData); break; case LocomotionAction.Jump: if (IsSliding && mode == Mode.PhysicsDriven && !jumpRequest.Active) { jumpRequest.Set(); base.Broadcaster.BroadcastOnDoAction(action, userData); } break; case LocomotionAction.Torpedo: case LocomotionAction.SlideTrick: break; } }
public override void DoAction(LocomotionAction action, object userData = null) { switch (action) { case LocomotionAction.Torpedo: case LocomotionAction.SlideTrick: break; case LocomotionAction.ChargeThrow: DefaultDoAction(action, userData); break; case LocomotionAction.LaunchThrow: DefaultDoAction(action, userData); break; case LocomotionAction.Interact: DefaultDoAction(action, userData); break; case LocomotionAction.Action1: case LocomotionAction.Action2: case LocomotionAction.Action3: DefaultDoAction(action, userData); break; case LocomotionAction.Jump: if (mode == Mode.Sitting) { mode = Mode.Exiting; exitingViaJump = true; } break; } }
private void SpawnCreature(JointGenerator generator) { var pos = new Vector3( x: _size.xMin + Random.value * _size.width, y: 3, z: _size.yMin + Random.value * _size.height ); var rootObject = generator.Instantiate(pos); var centralBody = rootObject.transform.GetChild(0).gameObject; Sensor.CreateComponent(centralBody, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f); var mouth = Mouth.CreateComponent(centralBody, typeof(Food)); var actions = LocomotionAction.EightDirections(); var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); var brain = new Brain( new FollowPointDecisionMaker(State.BasicKeys.RelativeFoodPosition), sequenceMaker ); var agent = Agent.CreateComponent(rootObject, brain, new Body(rootObject), actions); agent.name = RandomName(); var info = GameUI.AddAgent(agent); StartCoroutine(EntryPointUtility.Rename(info, agent, mouth)); }
private void sendLocomotionUpdate(Vector3 direction, LocomotionAction type) { LocomotionActionEvent action = default(LocomotionActionEvent); action.Type = type; action.Position = getCurrentPosition(); action.Direction = direction; LocomotionController currentController = locomotionTracker.GetCurrentController(); if (currentController is SlideController) { action.Velocity = currentController.GetFacing(); } if (broadcastingDisabledEvents == 0) { networkService.PlayerActionService.LocomotionAction(action, droppable: true); } AvatarDataHandle component = GetComponent <AvatarDataHandle>(); if (!(component == null) && broadcastingDisabledEvents == 0 && Service.Get <CPDataEntityCollection>().TryGetComponent(component.Handle, out PositionData component2)) { component2.Position = action.Position; if (!Service.Get <CPDataEntityCollection>().TryGetComponent(component.Handle, out PausedStateData component3)) { component3 = Service.Get <CPDataEntityCollection>().AddComponent <PausedStateData>(component.Handle); } component3.Position = component2.Position; } }
public static bool IsMovement(this LocomotionAction locomotionAction) { switch (locomotionAction) { case LocomotionAction.Move: case LocomotionAction.Jump: case LocomotionAction.Torpedo: case LocomotionAction.SlideTrick: return(true); default: return(false); } }
private void setLocomotionActionEvent(LocomotionAction locomotionAction, bool setDirection = false) { LocomotionActionEvent action = default(LocomotionActionEvent); action.Type = locomotionAction; action.Position = getCurrentPosition(); if (setDirection) { action.Direction = newSteerDirection; } if (broadcastingDisabledEvents == 0) { networkService.PlayerActionService.LocomotionAction(action); } }
public void Start() { action = GetLocomotionAction(); if (dirMap) { dirMap.Touched.AddListener(StartAction); dirMap.StateChanged.AddListener(UpdateTarget); dirMap.UnTouched.AddListener(EndAction); } //if (pointer && pointer.gameObject.activeSelf) // pointer.gameObject.SetActive(false); }
public virtual void EnableAction(LocomotionAction action, bool enabled) { switch (action) { case LocomotionAction.ChargeThrow: case LocomotionAction.LaunchThrow: { AbstractPenguinSnowballThrower component = GetComponent <AbstractPenguinSnowballThrower>(); if (component != null) { component.EnableSnowballThrow(enabled); } break; } } }
public override void DoAction(LocomotionAction action, object userData = null) { switch (action) { case LocomotionAction.Torpedo: if (curState == State.None) { animator.ResetTrigger(AnimationHashes.Params.AbortTorpedo); swim.Torpedo(); base.Broadcaster.BroadcastOnDoAction(action, userData); } break; case LocomotionAction.Interact: case LocomotionAction.Action3: DefaultDoAction(action, userData); break; } }
private GameObject SpawnCreature() { var rootObject = GameObject.CreatePrimitive(PrimitiveType.Cube); SuperFlexibleMove.CreateComponent(rootObject, speed: 1f); rootObject.AddComponent <Rigidbody>().freezeRotation = true; rootObject.GetComponent <Renderer>().material.color = Color.red; Sensor.CreateComponent(rootObject, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f); Mouth.CreateComponent(rootObject, typeof(Food)); var actions = LocomotionAction.EightDirections(); var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); var brain = new Brain( new FollowPointDecisionMaker(State.BasicKeys.RelativeFoodPosition), sequenceMaker ); Agent.CreateComponent(rootObject, brain, new Body(rootObject), actions); return(rootObject); }
public void JustSampleUsage() { var actions = LocomotionAction.EightDirections(); var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); var decisionMaker = new ReinforcementDecisionMaker(); var brain = new MotionGenerator.Brain( decisionMaker, sequenceMaker ); brain.Init( new Dictionary <Guid, int> { { Guid.NewGuid(), (new ManipulatableMock()).GetManipulatableDimention() } }, actions, new List <ISoul>() { new GluttonySoul() } ); // Position, Rotation is required to update LocomotionAction // GluttonySoul.Key is required to update GluttonySoul // others are used to decide action brain.GenerateMotionSequence(new State(new Dictionary <string, Vector>() { { State.BasicKeys.RelativeFoodPosition, DenseVector.OfArray(new double[] { 0.5f, 0.5f, 0.5f }) }, { State.BasicKeys.BirthPosition, DenseVector.OfArray(new double[] { 0f, 0f, 0f }) }, { State.BasicKeys.Position, DenseVector.OfArray(new double[] { 0f, 0f, 0f }) }, { State.BasicKeys.Rotation, DenseVector.OfArray(new double[] { 0f, 0f, 0f, 0f }) }, { GluttonySoul.Key, DenseVector.OfArray(new double[] { 0f }) } })); brain.GenerateMotionSequence(new State(new Dictionary <string, Vector>() { { State.BasicKeys.RelativeFoodPosition, DenseVector.OfArray(new double[] { 0.5f, 0.5f, 0.5f }) }, { State.BasicKeys.BirthPosition, DenseVector.OfArray(new double[] { 0f, 0f, 0f }) }, { State.BasicKeys.Position, DenseVector.OfArray(new double[] { 0.1f, 0f, 0f }) }, { State.BasicKeys.Rotation, DenseVector.OfArray(new double[] { 0f, 0f, 0f, 0f }) }, { GluttonySoul.Key, DenseVector.OfArray(new double[] { 1f }) } })); }
private GameObject SpawnCreature() { var prefab = (GameObject)Resources.Load("Prefabs/Car"); var car = Instantiate(prefab, Vector3.zero, Quaternion.identity); CarControlManipulatable.CreateComponent(car); Sensor.CreateComponent(car, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f); Mouth.CreateComponent(car, typeof(Food)); var actions = LocomotionAction.EightDirections(); var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); var brain = new Brain( new FollowPointDecisionMaker(State.BasicKeys.RelativeFoodPosition), sequenceMaker ); Agent.CreateComponent(car, brain, new Body(car), actions); return(car); }
protected void DefaultDoAction(LocomotionAction action, object userData = null) { switch (action) { case LocomotionAction.ChargeThrow: if (snowballThrow != null) { snowballThrow.ChargeSnowball(); } break; case LocomotionAction.LaunchThrow: if (snowballThrow != null) { snowballThrow.LaunchSnowball((float)userData); } break; case LocomotionAction.Interact: { PenguinInteraction component = GetComponent <PenguinInteraction>(); if (component != null && component.RequestInteraction()) { Broadcaster.BroadcastOnDoAction(action, userData); } break; } case LocomotionAction.Action1: case LocomotionAction.Action2: case LocomotionAction.Action3: { PenguinInteraction component = GetComponent <PenguinInteraction>(); if (component != null && !LocomotionUtils.IsInAir(LocomotionUtils.GetAnimatorStateInfo(animator))) { Broadcaster.BroadcastOnDoAction(action, userData); } break; } } }
public static Car CreateComponent(Vector3 vector3, Camera main) { var prefab = (GameObject)Resources.Load("Prefabs/Car"); var car = Instantiate(prefab, vector3, Quaternion.identity); CarControlManipulatable.CreateComponent(car); SurroundSensor.CreateComponent(car); Sensor.CreateComponent(car, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 300f); Mouth.CreateComponent(car, typeof(Food)); CrashSensor.CreateComponent(car); var actions = LocomotionAction.EightDirections(); var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); IDecisionMaker decisionMaker = new ReinforcementDecisionMaker( keyOrder: new[] { State.BasicKeys.Forward, State.BasicKeys.RelativeFoodPosition, SurroundSensor.Key }, soulWeights: new[] { 1f, 1f }); decisionMaker = new LoggingDecisionMaker(decisionMaker); var brain = new Brain( decisionMaker, sequenceMaker ); Agent.CreateComponent(car, brain, new Body(car), actions, souls: new List <ISoul>() { new SnufflingDifferencialSoul(), new AvoidCrashSoul() }); return(car.AddComponent <Car>()._CreateComponent(main, vector3)); }
private Agent StartCreature(GameObject creatureRootGameObject, GameObject centralBody) { // Add Sensor and Mouth for food Sensor.CreateComponent(centralBody, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f); var mouth = Mouth.CreateComponent(centralBody, typeof(Food)); // Initialize Brain var actions = LocomotionAction.EightDirections(); var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.1f, minimumCandidates: 30); var decisionMaker = new FollowPointDecisionMaker(State.BasicKeys.RelativeFoodPosition); var souls = new List <ISoul>() { new GluttonySoul() }; var brain = new Brain(decisionMaker, sequenceMaker); var agent = Agent.CreateComponent(creatureRootGameObject, brain, new Body(centralBody), actions, souls); var info = GameUI.AddAgent(agent); StartCoroutine(EntryPointUtility.Rename(info, agent, mouth)); return(agent); }
private void OnActionButtonClicked(LocomotionAction action) { if (animator != null) { int value = 1; switch (action) { case LocomotionAction.Action1: value = 1; break; case LocomotionAction.Action2: value = 2; break; case LocomotionAction.Action3: value = 3; break; } SetDanceMode(enable: true); animator.SetInteger("DanceMove", value); } }
private GameObject SpawnCreature(bool reinforcement = true) { var rootObject = new GameObject(); var creature = GameObject.CreatePrimitive(PrimitiveType.Cube); creature.transform.position = new Vector3( x: _size.xMin + Random.value * _size.width, y: 1, z: _size.yMin + Random.value * _size.height ); creature.transform.parent = rootObject.transform; SuperFlexibleMove.CreateComponent(creature, speed: 1f); creature.AddComponent <Rigidbody>().freezeRotation = true; creature.GetComponent <Renderer>().material.color = reinforcement ? Color.red : Color.yellow; Sensor.CreateComponent(creature, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f); var mouth = Mouth.CreateComponent(creature, typeof(Food)); var actions = LocomotionAction.EightDirections(); var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); if (reinforcement) { } var decisonMaker = reinforcement ? (IDecisionMaker) new ReinforcementDecisionMaker() : (IDecisionMaker) new FollowPointDecisionMaker(State.BasicKeys.RelativeFoodPosition); var brain = new Brain( decisonMaker, sequenceMaker ); var agent = Agent.CreateComponent(rootObject, brain, new Body(creature), actions); var info = GameUI.AddAgent(agent); agent.name = reinforcement ? "Reinforce" : "Rule"; StartCoroutine(EntryPointUtility.Rename(info, agent, mouth)); return(creature); }
public virtual void DoAction(LocomotionAction action, object userData = null) { }
public static Agent CreateComponent(Vector3 vector3, Camera main) { // var prefab = (GameObject) Resources.Load("Prefabs/Car"); // prefab.transform.localScale = prefab.transform.localScale * 5; // var creature = Instantiate(prefab, vector3, Quaternion.identity); // CarControlManipulatable.CreateComponent(creature); var prefab = (GameObject)Resources.Load("CreaturePrefabs/GymAnt"); prefab.transform.localScale = prefab.transform.localScale * 1; var creature = Instantiate(prefab, vector3, Quaternion.identity); foreach (var rigid in creature.GetComponentsInChildren <Rigidbody>()) { rigid.mass *= 300; rigid.solverIterations = 1000; rigid.collisionDetectionMode = CollisionDetectionMode.Continuous; } foreach (var collider in creature.GetComponentsInChildren <Collider>()) { collider.material = (Resources.Load <PhysicMaterial>("Ground")); } creature.transform.GetChild(0).GetComponent <Rigidbody>().mass *= 5; creature.transform.GetChild(0).GetComponent <Rigidbody>().angularDrag *= 15; UnityEngine.Debug.Log(creature.name); foreach (Transform part in creature.transform) { var obj = part.gameObject; if (obj == null) { continue; } obj.AddComponent <CrasherBehaviour>(); } BuildingSensor.CreateComponent(creature.transform.GetChild(0).gameObject, 500); var actions = LocomotionAction.EightDirections(); var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); // IDecisionMaker decisionMaker = new ReinforcementDecisionMaker( // keyOrder: new[] // { // State.BasicKeys.Forward, // State.BasicKeys.RelativeFoodPosition // }, soulWeights: new[] // { // 1f // }); // decisionMaker = new LoggingDecisionMaker(decisionMaker); IDecisionMaker decisionMaker = new FollowPointDecisionMaker(State.BasicKeys.RelativeFoodPosition); var brain = new Brain( decisionMaker, sequenceMaker ); var agent = Agent.CreateComponent(creature, brain, new Body(creature.transform.GetChild(0).gameObject), actions, souls: new List <ISoul>() { new SnufflingDifferencialSoul() }); creature.AddComponent <CrasherCreature>()._CreateComponent(main, vector3); return(agent); }
public override void DoAction(LocomotionAction action, object userData = null) { }