protected override void Initialize() { this.IsEnabledChanged += this.FoodComponent_IsEnabledChanged; this._player = this.Scene.GetAllComponentsOfType <PlayerComponent>().First(); this._spriteAnimator = this.GetChild <SpriteAnimationComponent>(); this._creatures.AddRange(this.Scene.GetAllComponentsOfType <CreatureComponent>()); this._crunchAudioPlayer = this.AddChild <AudioPlayer>(); this._crunchAudioPlayer.ShouldLoop = false; this._crunchAudioPlayer.Volume = 1f; this._hitAudioPlayer = this.AddChild <AudioPlayer>(); this._hitAudioPlayer.ShouldLoop = false; this._hitAudioPlayer.Volume = 1f; if (this._spriteAnimator == null) { this._spriteAnimator = this.AddChild <SpriteAnimationComponent>(); } this._spriteAnimator.DrawOrder = this.DrawOrder; this._spriteAnimator.SnapToPixels = true; this._spriteAnimator.FrameRate = 16; if (this._animation != null) { this._spriteAnimator.Play(this._animation, true); } }
public void Update() { PlayerDamageComponent playerDamageComponent = entityDatabase.QueryType <PlayerDamageComponent>(); if (!playerDamageComponent) { return; } Entity playerEntity = playerDamageComponent.entity; PlayerComponent playerComponent = playerEntity.GetComponent <PlayerComponent>(); playerComponent.audioSource.Play(); playerComponent.healthModel.health.value -= playerDamageComponent.amount; if (playerComponent.healthModel.health.value <= 0) { Death(playerComponent); } playerEntity.RemoveComponent <PlayerDamageComponent>(); entityDatabase.QueryType <EventComponent>().eventDispatcher.Dispatch(GameEvent.PlayerDamage); }
void ReceviceRemoveBuff(EntityBase entity, params object[] objs) { //Debug.Log("ReceviceRemoveBuff"); AddComp(entity); BuffEffectComponent bec = entity.GetComp <BuffEffectComponent>(); PlayerComponent pc = entity.GetComp <PlayerComponent>(); PerfabComponent pec = entity.GetComp <PerfabComponent>(); BuffInfo bi = (BuffInfo)objs[0]; if (bi.BuffData.m_BuffExitFX != "null") { EffectManager.ShowEffect(bi.BuffData.m_BuffExitFX, pec.perfab.transform.position, 0.5f); } BuffEffectPackage bep = bec.GetBuffEffectPackage(bi.buffID); //Debug.Log("bep >" + bep + "<"); if (bep != null && bep.buffEffectID != 0) { m_world.DestroyEntity(bep.buffEffectID); bep.buffEffectID = 0; } }
// ================================== PROTECTED ================================== // ------------------------------------------------------------------------------- // GetStartPosition // ------------------------------------------------------------------------------- protected Transform GetStartPosition(GameObject player) { //TODO: Add start position randomization here foreach (Transform startPosition in startPositions) { OpenMMO.Network.NetworkStartPosition position = startPosition.GetComponent <OpenMMO.Network.NetworkStartPosition>(); if (position == null || position.archeTypes.Length == 0) { continue; } PlayerComponent playerComponent = player.GetComponent <PlayerComponent>(); foreach (ArchetypeTemplate template in position.archeTypes) { if (template == playerComponent.archeType) { return(position.transform); } } } return(GetStartPosition()); }
public override void OnUpdate(float deltaTime) { if (onTankShootRequestedEvent.IsPublished) { foreach (var networkViewIDStr in onTankShootRequestedEvent.BatchedChanges) { int networkViewID = int.Parse(networkViewIDStr); PlayerProvider playerProvider = null; foreach (var p in playersFilter) { ref PlayerComponent pc = ref p.GetComponent <PlayerComponent>(); if (pc.networkPlayer.networkViewID == networkViewID) { playerProvider = pc.networkPlayer.GetPlayerProvider(); break; } } if (playerProvider == null) { continue; } Entity tankEntity = playerProvider.Entity; ref TankComponent tank = ref tankEntity.GetComponent <TankComponent>(); ProjectileProvider pp = ObjectSpawner.inst.InstantiateBullet(); ref ProjectileComponent projectile = ref pp.Entity.GetComponent <ProjectileComponent>();
private void BotControl(ref BodyComponent bodyComponent, PlayerComponent playerComponent, ref MoveComponent moveComponent, Vector2 finishPosition) { Vector2 vel = bodyComponent.Body.velocity; var velX = vel.x; var velY = vel.y; bool isMaxSpeedLeft = velX <= -playerComponent.Speed; bool isMaxSpeedRight = velX >= playerComponent.Speed; _force.x = 0; float botX = bodyComponent.Body.position.x; bool wereMovingToLeft = velX < 0; // were moving to the left bool goalFromTheLeft = botX > finishPosition.x; // goal is from the left bool toLeft = goalFromTheLeft; if (Mathf.Abs(velY) < 0.5f && Mathf.Abs(finishPosition.y - bodyComponent.Body.position.y) > 0.5f) { toLeft = wereMovingToLeft; } if (toLeft) { _force.x -= (isMaxSpeedLeft ? 0 : 1f); } else { _force.x += (isMaxSpeedRight ? 0 : 1f); } moveComponent.Force = _force * playerComponent.Power; moveComponent.Tourqe = Vector3.zero; }
public override void FixedUpdate(int deltaTime) { List <EntityBase> list = GetEntityList(); for (int i = 0; i < list.Count; i++) { PlayerComponent pc = (PlayerComponent)list[i].GetComp("PlayerComponent"); CollisionComponent cc = (CollisionComponent)list[i].GetComp("CollisionComponent"); pc.isCloak = false; pc.grassID = -1; for (int j = 0; j < cc.CollisionList.Count; j++) { EntityBase entityTmp = cc.CollisionList[j]; if (entityTmp.GetExistComp("GrassComponent")) { GrassComponent gc = (GrassComponent)entityTmp.GetComp("GrassComponent"); pc.isCloak = true; pc.grassID = gc.Entity.ID; } } } }
// ------------------------------------------------------------------------------- // LoginPlayer // @Server // ------------------------------------------------------------------------------- /// <summary> /// Method <c>LoginPlayer</c>. /// Run on the server. /// Logs in the player. /// </summary> /// <param name="conn"></param> /// <param name="username"></param> /// <param name="playername"></param> protected GameObject LoginPlayer(NetworkConnection conn, string username, string playername, int token) { string prefabname = DatabaseManager.singleton.GetPlayerPrefabName(playername); GameObject prefab = GetPlayerPrefab(prefabname); GameObject player = DatabaseManager.singleton.LoadDataPlayer(prefab, playername); PlayerComponent pc = player.GetComponent <PlayerComponent>(); // -- check the security token if required if (token == 0 || (token > 0 && pc.tablePlayerZones.ValidateToken(token))) { // -- log the player in DatabaseManager.singleton.LoginPlayer(conn, player, playername, username); NetworkServer.AddPlayerForConnection(conn, player); onlinePlayers.Add(player.name, player); state = NetworkState.Game; this.InvokeInstanceDevExtMethods(nameof(LoginPlayer), conn, player, playername, username); //HOOK eventListeners.OnLoginPlayer.Invoke(conn); //EVENT debug.LogFormat(this.name, nameof(LoginPlayer), username, playername); //DEBUG return(player); } return(null); }
public override void FixedUpdate(int deltaTime) { List <EntityBase> list = GetEntityList(); for (int i = 0; i < list.Count; i++) { CommandComponent cc = (CommandComponent)list[i].GetComp("CommandComponent"); SkillStatusComponent ssc = (SkillStatusComponent)list[i].GetComp("SkillStatusComponent"); PlayerComponent pc = (PlayerComponent)list[i].GetComp("PlayerComponent"); MoveComponent mc = (MoveComponent)list[i].GetComp("MoveComponent"); LifeComponent lc = (LifeComponent)list[i].GetComp("LifeComponent"); //CD for (int j = 0; j < ssc.m_skillList.Count; j++) { ssc.m_CDList[j] -= deltaTime; } if (ssc.skillDirCache.ToVector() != Vector3.zero && cc.isFire && !pc.GetIsDizziness() && lc.Life > 0 && cc.skillDir.ToVector() == Vector3.zero ) { string skillID = SkillUtils.GetSkillName(cc); SkillData data = ssc.GetSkillData(skillID); if (ssc.GetSkillCDFinsih(skillID)) { //Debug.Log("FIRE!!! --> " + skillID); ssc.m_skillTime = 0; ssc.m_skillStstus = SkillStatusEnum.Before; ssc.m_isTriggerSkill = false; ssc.m_currentSkillData = data; ssc.m_currentSkillData.UpdateInfo(); ssc.SetSkillCD(skillID, data.CDSpace); ssc.skillDir = ssc.skillDirCache.DeepCopy(); AreaDataGenerate areaData = DataGenerateManager <AreaDataGenerate> .GetData(ssc.m_currentSkillData.SkillInfo.m_EffectArea); float distance = ssc.skillDir.ToVector().magnitude; distance = areaData.m_SkewDistance + Mathf.Clamp(distance, 0, areaData.m_distance); Vector3 aimPos = mc.pos.ToVector() + ssc.skillDir.ToVector().normalized *distance; if (areaData.m_Shape != AreaType.Rectangle) { ssc.skillPos.FromVector(aimPos); } else { ssc.skillPos.FromVector(mc.pos.ToVector() + ssc.skillDir.ToVector().normalized *(areaData.m_SkewDistance - areaData.m_Length / 2)); } } } ssc.skillDirCache = cc.skillDir.DeepCopy(); } }
public bool EnablePlayerComponent(PlayerComponent component) { bool wasEnabled = false; switch (component) { case PlayerComponent.CameraRotationComp: cameraRotation.enabled = true; wasEnabled = true; break; case PlayerComponent.DrunkCameraComp: drunkCamera.enabled = true; wasEnabled = true; break; case PlayerComponent.GunComp: weaponHolder.EquippedGun.enabled = true; wasEnabled = true; onGunEnable.Invoke(); break; case PlayerComponent.WeaponHolderComp: weaponHolder.enabled = true; wasEnabled = true; break; case PlayerComponent.AnimatorComp: playerAnimator.enabled = true; wasEnabled = true; break; } return(wasEnabled); }
int frameCount = 0; //FRAME COUNTER void FixedUpdate() { //if (!PlayerComponent.localPlayer) return; //NOT LOGGED IN frameCount++; //INCREMENT TICK if (frameCount >= tickFrequency) //TICK THIS FRAME? { frameCount = 0; //RESET THE COUNTER GameObject player = transform.parent.gameObject; PlayerComponent pc = player.GetComponent <PlayerComponent>(); if (!pc) { pc = player.GetComponentInChildren <PlayerComponent>(); } if (player) { if (nameField != null && nameField.enabled) { nameField.text = player.name; //UPDATE PLAYER NAME } if (guildField != null && guildField.enabled) { guildField.text = "level " + pc.level; //UPDATE PLAYER GUILD (TODO: temporarily just level for proof of concept) } if (zoneField != null && zoneField.enabled) { zoneField.text = pc.currentZone.title; //UPDATE PLAYER ZONE } } } }
private static void SendPlayerUpdate( PortScanApplication portScan, PlayerComponent player, IServerApplication serverApplication) { if (player == null) { return; } ProcessInfo processInfo = new ProcessInfo(portScan); ProcessUpdateMessage processUpdate = new ProcessUpdateMessage( player.Id, processInfo, player.GetPublicIP()); processUpdate.Message = $"Found open port: {(int)serverApplication.Port} " + $"[{serverApplication.Port.ToString().ToUpper()}]"; Game.SendMessageToClient(player.Id, processUpdate.ToJson()); // TODO: Have debug config use this. Game.SendMessageToClient( player.Id, new TerminalUpdateMessage( $"Found open port: {(int)serverApplication.Port} " + $"[{serverApplication.Port.ToString().ToUpper()}]") .ToJson()); }
public static void Damage(WorldBase world, EntityBase attacker, EntityBase hurter, int damageNumber) { LifeComponent lc = hurter.GetComp <LifeComponent>(); //已经死亡不造成伤害 if (lc.life < 0) { return; } lc.Life -= damageNumber; world.eventSystem.DispatchEvent(GameUtils.GetEventKey(hurter.ID, CharacterEventType.Damage), hurter); if (lc.Life < 0) { if (attacker.GetExistComp <PlayerComponent>() && hurter.GetExistComp <PlayerComponent>() ) { PlayerComponent pc = attacker.GetComp <PlayerComponent>(); pc.score++; world.eventSystem.DispatchEvent(GameUtils.c_scoreChange, null); } } }
public TextSystem(DungeonCrawlerGame game) { _game = game; _actorTextComponent = _game.ActorTextComponent; _playerComponent = _game.PlayerComponent; _enemyComponent = _game.EnemyComponent; }
private void HandleInitNetworkInformation(NetIncomingMessage inc) { var cm = ComponentManager.Instance; var nrOfPlayers = inc.ReadInt32(); for (var i = 0; i < nrOfPlayers; i++) { var player = new PlayerComponent(); inc.ReadAllProperties(player); var e = EntityFactory.Instance.NewEntity(); cm.AddComponentToEntity(e, player); cm.AddComponentToEntity(e, new TransformComponent()); cm.AddComponentToEntity(e, new LapComponent()); var modelComp = new ModelComponent(_engine.LoadContent <Model>("kart"), true, false, false) { staticModel = false }; //ModelRenderSystem.AddMeshTransform(ref modelComp, 1, Matrix.CreateRotationY(0.2f)); //ModelRenderSystem.AddMeshTransform(ref modelComp, 3, Matrix.CreateRotationY(0.5f)); cm.AddComponentToEntity(e, modelComp); SceneManager.Instance.AddEntityToSceneOnLayer("Game", 3, e); } }
public void SetPlayerComponentsInRig(PlayerComponent component) { string propertyName = "walk"; switch (component.type) { case PlayerComponent.ComponentTypes.Walk: propertyName = "walk"; break; case PlayerComponent.ComponentTypes.Teleport: propertyName = "teleport"; break; case PlayerComponent.ComponentTypes.Rotate: propertyName = "rotate"; break; case PlayerComponent.ComponentTypes.Climb: propertyName = "climb"; break; case PlayerComponent.ComponentTypes.PhysicalBody: propertyName = "physicalBody"; break; } serializedObject.FindProperty(propertyName).objectReferenceValue = component; serializedObject.ApplyModifiedProperties(); }
public override void Update(float dt) { foreach (Entity entity in _entities) { PaddleComponent paddleComp = entity.GetComponent <PaddleComponent>(); PlayerComponent playerComp = entity.GetComponent <PlayerComponent>(); TransformComponent transformComp = entity.GetComponent <TransformComponent>(); Vector2 delta = Vector2.Zero; delta.Y += Constants.Pong.PADDLE_SPEED * playerComp.Input.GetAxis() * dt; transformComp.Move(delta); if (transformComp.Position.Y + paddleComp.Bounds.Y / 2 > Constants.Pong.PLAYFIELD_HEIGHT / 2) { transformComp.SetPosition(transformComp.Position.X, Constants.Pong.PLAYFIELD_HEIGHT / 2 - paddleComp.Bounds.Y / 2); } if (transformComp.Position.Y - paddleComp.Bounds.Y / 2 < -Constants.Pong.PLAYFIELD_HEIGHT / 2) { transformComp.SetPosition(transformComp.Position.X, -Constants.Pong.PLAYFIELD_HEIGHT / 2 + paddleComp.Bounds.Y / 2); } } }
//GameObject _waterObj; //UnderwaterEffect _underwaterEffect; protected virtual GameObject CreatePlayer(GameObject playerPrefab, Vector3 position, out GameObject playerCamera) { if (playerPrefab == null) { throw new InvalidOperationException("playerPrefab missing"); } var player = GameObject.FindWithTag("Player"); if (player == null) { player = GameObject.Instantiate(playerPrefab); player.name = "Player"; } player.transform.position = position; _playerTransform = player.GetComponent <Transform>(); var cameraInPlayer = player.GetComponentInChildren <Camera>(); if (cameraInPlayer == null) { throw new InvalidOperationException("Player:Camera missing"); } playerCamera = cameraInPlayer.gameObject; _playerComponent = player.GetComponent <PlayerComponent>(); //_underwaterEffect = playerCamera.GetComponent<UnderwaterEffect>(); return(player); }
public override void EventFired(object sender, Event evt) { if (evt is PulseEvent pe) { PlayerComponent player = WatchedComponents.FirstOrDefault() as PlayerComponent; if (player == null) { return; } double distance = (pe.Source - player.Owner.Components.Get <Spatial>().Position).Magnitude; if (distance < 0.1) { distance = 0.1; } if (distance > 64 && pe.Sender.Owner != player.Owner) { return; } VibrationAmount += Math.Pow(pe.Strength / 256, 2) * 256 / distance; if (VibrationAmount < 0.1) { VibrationAmount = 0; } } }
// ============================== MAJOR ACTIONS ================================== // ------------------------------------------------------------------------------- // AutoLoginPlayer // @Server // ------------------------------------------------------------------------------- protected void AutoLoginPlayer(NetworkConnection conn, string username, string playername, int token) { GameObject player = LoginPlayer(conn, username, playername, token); if (player) { PlayerComponent pc = player.GetComponent <PlayerComponent>(); // -- log the user in (again) LoginUser(conn, username); // -- update zone pc.tablePlayerZones.zonename = pc.currentZone.name; // -- warp to anchor location (if any) string anchorName = pc.tablePlayerZones.anchorname; if (pc.tablePlayerZones.startpos) // -- warp to start position { pc.WarpLocal(AnchorManager.singleton.GetArchetypeStartPositionAnchorName(player)); pc.tablePlayerZones.startpos = false; } else if (!String.IsNullOrWhiteSpace(anchorName)) // -- warp to anchor { pc.WarpLocal(anchorName); pc.tablePlayerZones.anchorname = ""; } } else { ServerSendError(conn, systemText.unknownError, true); } }
// ------------------------------------------------------------------------------- // OnTriggerEnter // @Client / @Server // ------------------------------------------------------------------------------- public override void OnTriggerEnter(Collider co) { GameObject player = PlayerComponent.localPlayer; if (!player) { return; } if (!triggerOnEnter) { PlayerComponent pc = player.GetComponent <PlayerComponent>(); if (pc.CheckCooldown) { UIPopupPrompt.singleton.Init(String.Format(popupEnter, targetZone.title), OnClickConfirm); } else { UIPopupNotify.singleton.Init(String.Format(popupWait, pc.GetCooldownTimeRemaining().ToString("F0"))); } } else if (player) { OnClickConfirm(); } }
private void Start() { var playerGO = Instantiate(playerPrefab); player = playerGO.GetComponent <PlayerComponent>(); player.damage = damage; }
// ------------------------------------------------------------------------------- // OnTriggerEnter // @Client / @Server // ------------------------------------------------------------------------------- public override void OnTriggerEnter(Collider co) { PlayerComponent pc = co.GetComponentInParent <PlayerComponent>(); if (pc == null || !pc.IsLocalPlayer) { return; } // -- can we switch zones? if (!ZoneManager.singleton.GetCanSwitchZone) { UIPopupNotify.singleton.Init(popupClosed); return; } if (!triggerOnEnter) { if (pc.CheckCooldown) { UIPopupPrompt.singleton.Init(String.Format(popupEnter, targetZone.title), OnClickConfirm); } else { UIPopupNotify.singleton.Init(String.Format(popupWait, pc.GetCooldownTimeRemaining().ToString("F0"))); } } else { OnClickConfirm(); } }
// ------------------------------------------------------------------------------- // OnClickConfirm // @Client // ------------------------------------------------------------------------------- public override void OnClickConfirm() { GameObject player = PlayerComponent.localPlayer; if (player == null) { return; } PlayerComponent pc = player.GetComponent <PlayerComponent>(); int index = UnityEngine.Random.Range(0, targetAnchors.Length); string targetAnchor = targetAnchors[index]; if (player && targetZone != null && !String.IsNullOrWhiteSpace(targetAnchor) && pc.CheckCooldown) { pc.WarpRemote(targetAnchor, targetZone.name); } base.OnClickConfirm(); if (UIPopupNotify.singleton) { UIPopupNotify.singleton.Init(popupZoning, 10f, false); } }
/// <summary> /// Creates a player from a given user object - this is an entity ready to be sent into a simulation game. /// </summary> /// <param name="user"></param> /// <returns></returns> public static Entity CreatePlayer(User user, Vector2 location) { var entity = new Entity(); var transformComponent = new TransformComponent(location, new Vector2(50, 70)); var nameComponent = new NameComponent(user.Name); var skinComponent = new SkinComponent(user.SessionConfig.Skin); var playerComponent = new PlayerComponent(); var bombModifier = new BombCountModifierComponent(); var rangeModifier = new RangeModifierComponent(); var movementModifier = new MovementModifierComponent(); // Add modifier components to the sprite playerComponent.Connection = user.Connection; playerComponent.SecureToken = user.SecureToken; entity.AddComponent(transformComponent); entity.AddComponent(nameComponent); entity.AddComponent(skinComponent); entity.AddComponent(playerComponent); entity.AddComponent(bombModifier); entity.AddComponent(rangeModifier); entity.AddComponent(movementModifier); return(entity); }
/// <summary> /// 创建角色事件 /// </summary> void CreatePlayerEvent(SCCreatePlayer info) { UnitData heroData = new UnitData(); heroData.HPValue = 100; heroData.IsAddSpeed = false; heroData.IsAttack = false; heroData.JiFen = 0; heroData.PlayerId = info.PlayerId; heroData.Postion = new Vector3(info.x, info.y, info.z); if (!playerDic.ContainsKey(info.PlayerId)) { var player = CreatePlayer(heroData); if (info.PlayerId == channel01.LocalPort) { CreateHero(player); } else { PlayerComponent hero = GetHeroPlayer(); channel01.Send <SCCreatePlayer>(new SCCreatePlayer() { PlayerId = hero.playerUnitData.PlayerId, x = hero.transform.position.x, y = hero.transform.position.y, z = hero.transform.position.z, }); } } }
public static Unit GetMyUnitFromClientScene(Scene clientScene) { PlayerComponent playerComponent = clientScene.GetComponent <PlayerComponent>(); Scene currentScene = clientScene.GetComponent <CurrentScenesComponent>().Scene; return(currentScene.GetComponent <UnitComponent>().Get(playerComponent.MyId)); }
// ------------------------------------------------------------------------------- // OnTriggerEnter // @Client / @Server // ------------------------------------------------------------------------------- public override void OnTriggerEnter(Collider co) { if (targetAnchor == null) { debug.LogWarning("You forgot to set an anchor to WarpPortal: " + this.name); return; } PlayerComponent pc = co.GetComponentInParent <PlayerComponent>(); if (pc == null || !pc.IsLocalPlayer) { return; } if (!triggerOnEnter) { if (pc.CheckCooldown) { UIPopupPrompt.singleton.Init(String.Format(popupEnter, targetAnchor), OnClickConfirm); } else { UIPopupNotify.singleton.Init(String.Format(popupWait, pc.GetCooldownTimeRemaining().ToString("F0"))); } } else { OnClickConfirm(); } }
/// <summary> /// Process each porstcan application. /// </summary> /// <returns>Whether system should continue processing after this iteration.</returns> public bool Process( Entity originEntity, PortScanApplication portScan, ComputerComponent originComputer) { if (portScan.SecondsSinceLastUpdate < Delay) { portScan.SecondsSinceLastUpdate += Game.Time.ElapsedSeconds; return(true); } PlayerComponent player = originEntity.GetComponent <PlayerComponent>(); ComputerComponent targetComputer = Game.World.GetEntityById(portScan.TargetEntityId)? .GetComponent <ComputerComponent>(); if (!ValidateHost( targetComputer: targetComputer, player: player)) { return(false); } ScanCurrentPort( portScan: portScan, targetComputer: targetComputer, player: player); if (!IncrementCurrentPort(portScan)) { return(false); } return(true); }
public override void BeforeFixedUpdate(int deltaTime) { List <EntityBase> list = GetEntityList(); for (int i = 0; i < list.Count; i++) { CommandComponent com = list[i].GetComp <CommandComponent>(); MoveComponent move = list[i].GetComp <MoveComponent>(); PlayerComponent pc = list[i].GetComp <PlayerComponent>(); LifeComponent lc = list[i].GetComp <LifeComponent>(); BlowFlyComponent blc = list[i].GetComp <BlowFlyComponent>(); if (lc.Life > 0 && !blc.isBlow && !pc.GetIsDizziness()) { pc.faceDir = com.skillDir.DeepCopy(); move.dir = com.moveDir.DeepCopy(); move.m_velocity = pc.GetSpeed(); } else { move.dir.FromVector(Vector3.zero); } } }
public void IncludesEntityGroup() { var component = PlayerComponent.Create(); JsonElement deserialized = JsonSerializer.Deserialize <JsonElement>(component.Save()); Assert.Equal(PlayerComponent.ENTITY_GROUP, deserialized.GetProperty("EntityGroup").GetString()); }
/// <summary> /// Creates a new HUDSystem. /// </summary> /// <param name="game">Parent game.</param> public HUDSystem(DungeonCrawlerGame game) { _game = game; _content = game.Content; _playerComponent = game.PlayerComponent; _p1 = new HUDSprite { Show = false }; _p2 = new HUDSprite { Show = false }; _p3 = new HUDSprite { Show = false }; _p4 = new HUDSprite { Show = false }; }
/// <summary> /// Creates a new HUDSystem. /// </summary> /// <param name="game">Parent game.</param> public HUDSystem(DungeonCrawlerGame game) { _game = game; _content = game.Content; _playerComponent = game.PlayerComponent; spriteBatch = new SpriteBatch(game.GraphicsDevice); _p1 = new HUDSprite { Show = false }; _p2 = new HUDSprite { Show = false }; _p3 = new HUDSprite { Show = false }; _p4 = new HUDSprite { Show = false }; }
/* Generates and inflicts damage if necessary */ public void doDamage(AttributeComponent attackingPlayerAttr, PlayerComponent attackingPlayerComp, AttributeComponent damageTakingPlayerAtrr, int damageFlag) { switch(damageFlag) { case SHOOT: int damage = generateShootDamage(attackingPlayerAttr, damageTakingPlayerAtrr); inflictShootDamage(attackingPlayerAttr, attackingPlayerComp, damageTakingPlayerAtrr, damage); break; default: break; } }
public bool shoot(GameObject attacker, GameObject target) { healthSystem = GameObject.Find("Manager").GetComponent<HealthSystem>(); currentplayerAttr = (AttributeComponent)attacker.GetComponent(typeof(AttributeComponent)); currentPlayerCell = currentplayerAttr.getCurrentCell(); currentPlayerWeapon = (WeaponComponent)currentplayerAttr.weapon.GetComponent(typeof(WeaponComponent)); if(attacker.tag == "FigurSpieler1") currentPlayerComp = GameObject.Find("Player1").GetComponent<PlayerComponent>(); else currentPlayerComp = GameObject.Find("Player2").GetComponent<PlayerComponent>(); currentTargetAttr = (AttributeComponent)target.GetComponent(typeof(AttributeComponent)); currentTargetCell = currentTargetAttr.getCurrentCell(); distanceBetweenPlayers = Vector3.Magnitude(currentTargetCell.transform.position - currentPlayerCell.transform.position); Debug.Log("Distance between players is " + distanceBetweenPlayers); if (playerCanShoot()) { float hitChance = chanceOfHittingTarget(); Debug.Log("Hitchance: " + hitChance); if (hitChance >= Random.value) { if (healthSystem == null) Debug.Log("Healthsys"); if (currentplayerAttr == null) Debug.Log("currentplayerAttr"); if (currentPlayerComp == null) Debug.Log("currentPlayerComp"); if (currentTargetAttr == null) Debug.Log("currentTargetAttr"); healthSystem.doDamage(currentplayerAttr, currentPlayerComp, currentTargetAttr, HealthSystem.SHOOT); return true; } else { return false; } } return false; }
private void onLogin(LoginResponsePacket packet) { var id = packet.OwnerEntityId; var entity = EntityManager.GetEntityByUniqueId(id); if (entity == null) { entity = ObjectMapper.CreateEntityById(id); } PlayerComponent pComp = new PlayerComponent(null); entity.AddComponent(pComp); _thisPlayer = entity; }
private void OnLogin(MonoLoginPacket obj) { var midgard = LookupSystem<Midgard>(); var playerComponent = new PlayerComponent(obj.Connection); var entity = _playerSys.Add(playerComponent); RenderData renderData = (RenderData)ObjectMapper.Create((uint)entity.UniqueId, typeof(RenderData)); renderData.Set(midgard, entity, _monoServer.Content); entity.AddComponent(renderData); LoginResponsePacket packet = new LoginResponsePacket(); packet.OwnerEntityId = (uint)entity.UniqueId; _bifrost.Send(packet, obj.Connection); }
public Toolbar(IScreenManager screenManager, PlayerComponent player) : base(screenManager) { Player = player; toolTextures = new Dictionary<string, Texture2D>(); }
private void inflictShootDamage(AttributeComponent attackingPlayerAttr, PlayerComponent attackingPlayerComp, AttributeComponent damageTakingPlayerAttr, int damage) { Debug.Log("Damage taken : " + damage); damageTakingPlayerAttr.hp -= damage; attackingPlayerComp.useAP(); attackingPlayerAttr.canShoot = false; //Zeug für Animationen anim = damageTakingPlayerAttr.model.GetComponent<Animator>(); anim.SetTrigger(animId_tgetHit); if (damageTakingPlayerAttr.hp <= 0) killFigurine(damageTakingPlayerAttr); }
public InventoryScreen(IScreenManager screenManager, PlayerComponent player) : base(screenManager) { this.player = player; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); SkillEntityFactory = new SkillEntityFactory(this); NPCFactory = new NPCFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); NpcAIComponent = new NpcAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); NPCComponent = new NPCComponent(); //QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); SoundComponent = new SoundComponent(); ActorTextComponent = new ActorTextComponent(); TurretComponent = new TurretComponent(); TrapComponent = new TrapComponent(); ExplodingDroidComponent = new ExplodingDroidComponent(); HealingStationComponent = new HealingStationComponent(); PortableShieldComponent = new PortableShieldComponent(); PortableStoreComponent = new PortableStoreComponent(); ActiveSkillComponent = new ActiveSkillComponent(); PlayerSkillInfoComponent = new PlayerSkillInfoComponent(); Quests = new List<Quest>(); #region Initialize Effect Components AgroDropComponent = new AgroDropComponent(); AgroGainComponent = new AgroGainComponent(); BuffComponent = new BuffComponent(); ChanceToSucceedComponent = new ChanceToSucceedComponent(); ChangeVisibilityComponent = new ChangeVisibilityComponent(); CoolDownComponent = new CoolDownComponent(); DamageOverTimeComponent = new DamageOverTimeComponent(); DirectDamageComponent = new DirectDamageComponent(); DirectHealComponent = new DirectHealComponent(); FearComponent = new FearComponent(); HealOverTimeComponent = new HealOverTimeComponent(); InstantEffectComponent = new InstantEffectComponent(); KnockBackComponent = new KnockBackComponent(); TargetedKnockBackComponent = new TargetedKnockBackComponent(); ReduceAgroRangeComponent = new ReduceAgroRangeComponent(); ResurrectComponent = new ResurrectComponent(); StunComponent = new StunComponent(); TimedEffectComponent = new TimedEffectComponent(); EnslaveComponent = new EnslaveComponent(); CloakComponent = new CloakComponent(); #endregion base.Initialize(); }
public Compass(IScreenManager screenManager, PlayerComponent player) : base(screenManager) { Player = player; }
public DebugInfos(IScreenManager screenManager, PlayerComponent player) : base(screenManager) { framebuffer = new float[buffersize]; Player = player; }
public Toolbar(IScreenManager screenManager, PlayerComponent player) : base(screenManager) { Player = player; }
public WinWhenAllEnemyUnitsDead(PlayerComponent enemy, ScenarioComponent scenario) { condition = new ConditionAllPlayerUnitsDead(this,enemy); this.scenario = scenario; action = new PlayerWinAction(this, scenario); }
public void Initialize(InputContext inputContext) { this.inputContext = inputContext; playerComponent = Owner.Components.Get<PlayerComponent>(); spatialComponent = Owner.Components.Get<SpatialComponent>(); controller = spatialComponent.RigidBody.Tag as CharacterController; var globalSettings = ServiceLocator.Get<GlobalSettings>(); messageHandler = ServiceLocator.Get<IMessageHandler>(); gameClient = ServiceLocator.Get<IGameClient>(); // Movement lookAroundAmplifier = globalSettings.Player.Movement.LookAroundAmplifier; movementAmplifier = globalSettings.Player.Movement.MovementAmplifier; crouchingMovementReduction = globalSettings.Player.Movement.CrouchingMovementReduction; IsEnabled = true; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); //TurretComponent = new TurretComponent(); //TrapComponent = new TrapComponent(); //PortableShopComponent = new PortableShopComponent(); //PortableShieldComponent = new PortableShieldComponent(); //MotivateComponent = new MotivateComponent(); //FallbackComponent = new FallbackComponent(); //ChargeComponent = new ChargeComponent(); //HealingStationComponent = new HealingStationComponent(); //ExplodingDroidComponent = new ExplodingDroidComponent(); base.Initialize(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); CharacterSelectionScreen = new CharacterSelectionScreen(graphics, this); LevelManager = new LevelManager(this); base.Initialize(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); base.Initialize(); }