public bool SwapPlayerChar(CharacterComponent charac) { if (charac.Equals(currPlayerChar)) { return(false); } //remove highlight HighlightManager.instance.ClearHighlight(); //swap currChar and charac position in turnOrder //(since curr is already dequeued, then remove the charac from the order and get the new one) turnOrders.ReplaceItem(charac, currPlayerChar); //swap charId int tempId = charac.charId; charac.charId = currPlayerChar.charId; currPlayerChar.charId = tempId; //replace currChar isPlayer to new one currPlayerChar.RevokePlayer(); SetPlayerChar(charac); //replace currUnit to this char currUnit = charac; //change to new charac turn currUnit.MyTurn(); return(true); }
public void ShowHitChance() { CharacterComponent player = _playerControl.CharacterComponent; if (!CanShowHud()) { _huds.Cleanup(); return; } PlayerHUD_Proxy playerHud = new PlayerHUD_Proxy(Game.World.HUD); Node movementTarget = playerHud.FindMovementTargetNode(); HashSet <String> remainingHuds = _huds.GetKnownHudNames(); using (PinnedCharacterPosition.Hack(player, movementTarget)) { foreach (VisibleTargetHud visible in EnumerateVisibleEnemyHuds(player)) { if (!visible.TryGetAimInfo(_playerControl, out String aimInfo)) { continue; } TargetHitHud hud = _huds.ProvideHud(playerHud, visible.Character); hud.Refresh(visible.ScreenPoint, aimInfo); remainingHuds.Remove(hud.Name); } } remainingHuds.Do(_huds.DisableHud); }
public override void Begin(eCampaignCharacterState previousState) { base.Begin(previousState); GameObject target = Targeting.AttackTarget; if (target != null) { CharacterComponent targetCharacter = target.GetComponent <CharacterComponent>(); if (targetCharacter != null && targetCharacter.Model != null && targetCharacter.Model.team == eTeamId.Interactable) { return; } } if (!IsPlayingAttack || previousState != eCampaignCharacterState.AttackTarget) { Combat.ResetAttackSequence(); RefreshComboAttack(); _hasStartedFirstAttack = false; if (!Combat.CanMoveAndAttack) { _canInterruptMove = false; } } Locomotion.ShouldIgnoreRotation = true; SetDesiredAnimationState(global::MoveController.CombatantMoveState.kAttackTarget); }
public void AfterTest() { GameServiceProvider.ClearGameServiceProvider(); _characterComponent = null; _inputBinder = null; }
//锁定一个普通攻击范围内的目标 可选择建筑 public bool LockAttackTarget() { CharacterComponent myself = myGamer.GetComponent <CharacterComponent>(); List <Gamer> inViewGamers = new List <Gamer>(); foreach (var a in mobaIDGamers.Values) { //排除法 去除本地玩家 隐身中的玩家 无敌的玩家 同阵营玩家 CharacterComponent enemy = a.GetComponent <CharacterComponent>(); if (enemy == null) { continue; } if (!enemy.isAlive) { continue; } if (a.UserID == myGamer.UserID) { continue; } if (enemy.isInvisible) { continue; } if (!enemy.isAttackable) { continue; } if (enemy.group == myself.group) { continue; } if (Vector3.Distance(a.Position, myGamer.Position) > myself.attackRange) { continue; } if (enemy.type == 1) //优先返回英雄目标 { target = a; return(true); } else if (enemy.type == 3) //次优先返回建筑目标 { target = a; return(true); } inViewGamers.Add(a); } if (inViewGamers.Count == 0) { return(false); } //使用比较器选出最近的角色 target = inViewGamers[0]; return(true); }
// perform any initialization on dialogue participants static private void EnterParticipantsToDialogue() { if (null != activeDialogue.dialoguePoints) { for (int dialogue = 0; dialogue < activeDialogue.dialoguePoints.Count; ++dialogue) // go through all dialogue conversation points { if (null != activeDialogue.dialoguePoints[dialogue]) { GameObject caller = GlobalUtils.FindCharacter(activeDialogue.dialoguePoints[dialogue].caller); if (null != caller) { CharacterComponent charComp = caller.GetComponent <CharacterComponent>(); if (null != charComp) { AnimationSequence.SetAnimationEnterState(charComp); // start the dialogue enter animation if (null != charComp.TargetingComponent) { charComp.TargetingComponent.SetMovementTarget(Vector3.zero, true); // stop the character movement charComp.TargetingComponent.SetAttackTarget(null); // stop the character attacking } } //_interaction.SwitchCharacterTeam(caller.GetComponent<NPCStatsComponent>()); // stop an enemy from being targetable } } } } }
public void Awake() { _characterComponent = GetComponent <CharacterComponent>(); _network = GetComponent <NetworkOwnershipComponent>(); _viewRPC = FindReplicationViewForComponent <CharacterTargetingComponent>(); }
/// <summary> /// Called when the script is first initialized /// </summary> public override void Start() { base.Start(); // Get the navigation component on the same entity as this script navigation = Entity.Get <NavigationComponent>(); // Will search for an CharacterComponent within the same entity as this script character = Entity.Get <CharacterComponent>(); if (character == null) { throw new ArgumentException("Please add a CharacterComponent to the entity containing PlayerController!"); } if (PunchCollision == null) { throw new ArgumentException("Please add a RigidbodyComponent as a PunchCollision to the entity containing PlayerController!"); } modelChildEntity = Entity.GetChild(0); moveDestination = Entity.Transform.WorldMatrix.TranslationVector; PunchCollision.Enabled = false; }
public void Setup(CharacterComponent source, Vector3 direction) { Source = source; Direction = direction; Origin = transform.position; life = 2; }
/// <summary> /// Called when the script is first initialized /// </summary> public override void Start() { base.Start(); navigation = Entity.Get <NavigationComponent>(); character = Entity.Get <CharacterComponent>(); if (character == null) { throw new ArgumentException("Please add a CharacterComponent to the entity containing PlayerController!"); } if (PunchCollision == null) { throw new ArgumentException("Please add a RigidbodyComponent as a PunchCollision to the entity containing PlayerController!"); } modelChildEntity = Entity.GetChild(0); moveDestination = Entity.Transform.WorldMatrix.TranslationVector; PunchCollision.Enabled = false; beepSoundInstance = BeepEffect?.CreateInstance(); beepSoundInstance.Stop(); commandInterpreter.moveHandler = RemoteMove; commandInterpreter.moveCurrentHandler = RemoteMoveCurrentDirection; commandInterpreter.canMoveHandler = RemoteCanMove; commandInterpreter.turnHandler = RemoteTurn; commandInterpreter.haltHandler = HaltMovement; commandInterpreter.beepHandler = PlayBeep; commandInterpreter.signalHandler = Signal; commandInterpreter.markerHandler = MarkerUpDown; }
private static void CreateOrDestroyEntities(EcsWorld world, EcsFilter filter, int count, Action <EcsWorld> createEntity) { IEcsGroup group = world.Filter(filter); if (group.CalculateCount() == count) { return; } IEcsEntity[] entities = group.ToEntityArray(); for (int i = entities.Length; i < count; i++) { createEntity(world); } for (int i = count; i < entities.Length; i++) { IEcsEntity entity = entities[i]; BroadphaseRefComponent brRef = entity.GetComponent <BroadphaseRefComponent>(); CharacterComponent character = entity.GetComponent <CharacterComponent>(); Object.Destroy(character.Ref.gameObject); foreach (SAPChunk chunk in brRef.Chunks) { BroadphaseHelper.RemoveFormChunk(chunk, entity.Id); } entity.Destroy(); } }
public override void Start() { playerSprite = Entity.Get <SpriteComponent>(); playerController = Entity.Get <CharacterComponent>(); //Please remember that in the GameStudio element the parameter Step Height is extremely important, it not set properly it will cause the entity to snap fast to the ground playerController.JumpSpeed = 5.0f; playerController.Gravity = new Vector3(0.0f, -10.0f, 0.0f); playerController.FallSpeed = 10.0f; playerController.ProcessCollisions = true; if (!IsLiveReloading) { Script.AddTask(async() => { while (Game.IsRunning) { var collision = await playerController.NewCollision(); // Stop if we collide from side foreach (var contact in collision.Contacts) { if (contact.Normal.X < -0.5f || contact.Normal.X > 0.5f) { movingToTarget = false; break; } } } }); PlayIdle(); } }
private static IEnumerable <VisibleTargetHud> EnumerateVisibleEnemyHuds(CharacterComponent player) { Rect screenArea = Screen.safeArea; foreach (BehaviorComponent behaviorComponent in Game.World.Behaviors) { if (!(behaviorComponent is CharacterComponent cc)) { continue; } if (cc.IsDead()) { continue; } Vector3 screenPoint = Camera.main.WorldToScreenPoint(behaviorComponent.transform.position); screenPoint.x += 20f; screenPoint.y -= 35f; if (!screenArea.Contains(screenPoint)) { continue; } if (!cc.IsEnemy(player)) { continue; } yield return(new VisibleTargetHud(cc, screenPoint)); } }
static public GameObject FindCharacter(CharacterModel characterRequired) { if (null == characterRequired) { return(null); } PlayerController localPlayer = PlayerManager.LocalPlayerController(); if (null != localPlayer) { if (characterRequired.isPlayer) // if any player character is specified { return(localPlayer.gameObject); } //else if (IsPixieCharacterModel(characterRequired)) //{ // return localPlayer.Pixie; //} else { return(null); } } CharacterComponent charComp = CharacterComponentManager.sCharacterComponents.Find(comp => comp.Model == characterRequired); if (null != charComp) { return(charComp.gameObject); } return(null); }
/// <summary> /// Called when the script is first initialized /// </summary> public override void Start() { base.Start(); // Get the navigation component on the same entity as this script Navigation = Entity.Get <NavigationComponent>(); // Will search for an CharacterComponent within the same entity as this script Character = Entity.Get <CharacterComponent>(); if (Character == null) { throw new ArgumentException("Please add a CharacterComponent to the entity containing PlayerController!"); } //if (PunchCollision == null) throw // new ArgumentException("Please add a RigidbodyComponent as a PunchCollision to the entity containing PlayerController!"); ModelChildEntity = Entity.GetChild(0); MoveToDestination = Entity.Transform.WorldMatrix.TranslationVector; //PunchCollision.Enabled = false; Entity atimerE = new Entity { new Core.Timer() }; SceneSystem.SceneInstance.RootScene.Entities.Add(atimerE); AttackTimer = atimerE.Get <Core.Timer>(); }
/// <summary> /// Called when the script is first initialized /// </summary> public override void Start() { base.Start(); // Will search for an CharacterComponent within the same entity as this script character = Entity.Get<CharacterComponent>(); if (character == null) throw new ArgumentException("Please add a CharacterComponent to the entity containing PlayerController!"); }
public void AfterTest() { _playerCamera = null; _characterComponent = null; _actionStateMachine = null; _inputBinder = null; }
public void SetPlayerChar(CharacterComponent charac) { currPlayerChar = charac; currPlayerChar.SetToPlayer(); playerArea.transform.position = currPlayerChar.transform.position; playerArea.transform.parent = currPlayerChar.transform; }
public override void Execute(GameObject actor) { if (_actor != actor) { _actor = actor.GetComponent <CharacterComponent>(); } _actor.Fire(); }
public void ExecuteAction(CardData data) { currentTarget = characters.First(); HandlePush(data); currentTarget.ExecuteAction(data); }
public override void AffectToCharacter(CharacterComponent character) { // 毒無効の特性を持っていない場合は毒状態にする if (!character.CharacterCharacteristics.Contains(CharacterCharacteristic.PoisonGuard)) { character.CharacterStates.Add(CharacterState.Poison); } }
private static void SetPlayerTransform( SimulationTickNumber simulationTickNumber, MovementSnapshotsComponent movementSnapshotsComponent, CharacterComponent characterComponent, ref Vector3 position, ref Quaternion rotation) { Debug.Assert(movementSnapshotsComponent != null); ref var movementData = ref movementSnapshotsComponent.SnapshotStore.GetOrCreate(simulationTickNumber);
public void Run() { foreach (int index in _ecsFilter) { MoveComponent moveComponent = _ecsFilter.Get1[index]; CharacterComponent characterComponent = _ecsFilter.Get2[index]; characterComponent.Transform.position += moveComponent.Value * Time.deltaTime; } }
public override void onAddedToEntity() { _platformerObject = entity.getComponent <PlatformerObject>(); _characterComponent = entity.getComponent <CharacterComponent>(); sprite = entity.getComponent <AnimatedSprite>(); entity.setTag(GlobalConstants.PLAYER_TAG); }
public override void Start() { desiredYaw = yaw = (float) Math.Asin(2 * Entity.Transform.Rotation.X * Entity.Transform.Rotation.Y + 2 * Entity.Transform.Rotation.Z * Entity.Transform.Rotation.W); desiredPitch = pitch = (float) Math.Atan2( 2 * Entity.Transform.Rotation.X * Entity.Transform.Rotation.W - 2 * Entity.Transform.Rotation.Y * Entity.Transform.Rotation.Z, 1 - 2 * Entity.Transform.Rotation.X * Entity.Transform.Rotation.X - 2 * Entity.Transform.Rotation.Z * Entity.Transform.Rotation.Z); Input.LockMousePosition(true); Game.IsMouseVisible = false; character = Entity.Get <CharacterComponent>(); if (character == null) { Log.Error("Could not find a physics character component (" + Entity.Name + ")"); character = new CharacterComponent(); Entity.Add(character); //this is currently the only way to make sure the physics element is actually created. SceneSystem.SceneInstance.RootScene.Entities.Remove(Entity); SceneSystem.SceneInstance.RootScene.Entities.Add(Entity); } if (CameraEntity == null) { for (int index = 0; index < Entity.Transform.Children.Count; index++) { var child = Entity.Transform.Children[index]; var camera = child.Entity.Get <CameraComponent>(); if (camera != null) { CameraEntity = child.Entity; break; } } if (CameraEntity == null) { Log.Error("Could not find a camera component. (" + Entity.Name + ")"); } } if (CameraEntity != null) { baseCameraRotation = CameraEntity.Transform.Rotation; } }
public PinnedCharacterPosition(CharacterComponent cc) { Character = cc; Cell = cc.GetCell(); _originalX = Cell.X; _originalY = Cell.Y; _originalPosition = cc.transform.position; }
public void BeforeTest() { _inputBinder = new GameObject().AddComponent <MockInputBinderComponent>(); _actionStateMachine = _inputBinder.gameObject.AddComponent <MockActionStateMachineComponent>(); _characterComponent = _inputBinder.gameObject.AddComponent <CharacterComponent>(); _inputBinder.gameObject.AddComponent <TestUnityMessageEventDispatcherComponent>().TestAwake(); _characterComponent.ActiveController = _inputBinder.gameObject.AddComponent <ControllerComponent>(); _playerCamera = _characterComponent.ActiveController.gameObject.AddComponent <MockPlayerCameraComponent>(); }
public void PlayCharacter(CharacterComponent character) { if (_controlledCharacter != null) { _controlledCharacter.GetComponent <NavMeshAgent> ().enabled = false; _controlledCharacter.PlayedSquares = 0; } _controlledCharacter = character; Map.ActivateColor(_controlledCharacter.AffinityColor); }
public override void Start() { character = Entity.Get <CharacterComponent>(); character.Gravity = -10.0f; var rigidBodyComponent = Entity.Get <RigidbodyComponent>(); if (rigidBodyComponent != null) { rigidBodyComponent.CanSleep = false; } }
internal static void SimulateCharacter(CharacterComponent characterComponent, Simulation simulation, float deltaTimeInSeconds) { _simulateCharacterComponentFunction ??= CreateSimulateCharacterComponentFunction(characterComponent); _updateTransformFromPhysicsComponentFunction ??= CreateUpdateTransformFromPhysicsComponentFunction(); _simulateCharacterComponentFunction(characterComponent, simulation, deltaTimeInSeconds); var physicsObjectWorldMatrix = Matrix.RotationQuaternion(characterComponent.Orientation) * characterComponent.PhysicsWorldTransform; _updateTransformFromPhysicsComponentFunction(characterComponent, ref physicsObjectWorldMatrix); }