public Ennemy() { m_location = new LocationComponent(this); m_move = new MoveComponent(this, m_location); m_rigidBody = new RigidBodyComponent(this, m_location); m_life = new LifeComponent(this, 50); var r = (byte)RandomGenerator.Instance.Random.Next(0, 255); var g = (byte)RandomGenerator.Instance.Random.Next(0, 255); var b = (byte)RandomGenerator.Instance.Random.Next(0, 255); m_bloodColor = new Color4ub(r, g, b, 255); }
public void ECSBeAttack(EntityBase entity, params object[] pbjs) { Debug.Log("ECSBeAttack " + entity.World.FrameCount); PerfabComponent pc = entity.GetComp <PerfabComponent>(); LifeComponent lc = entity.GetComp <LifeComponent>(); PlayerComponent plc = entity.GetComp <PlayerComponent>(); CampComponent cc = entity.GetComp <CampComponent>(); //Debug.Log("BeAttack -->"); UpdateLifeSlider((float)lc.Life / (float)lc.maxLife); UpdateSliderLength(0, lc.maxLife); TextDisplaySizeType textSizeType = TextDisplaySizeType.Small; //if ((bool)args[1] == true) //{ // textSizeType = TextDisplaySizeType.Large; //} DisplayNum(n_oldHp - lc.Life, cc.camp, textSizeType, TextDisplayStyleType.Hurt); n_oldHp = lc.Life; }
public void PlayerJoin(EntityBase entity) { PlayerComponent playerComp = null; if (!entity.GetExistComp <PlayerComponent>()) { playerComp = new PlayerComponent(); playerComp.characterID = "1"; playerComp.nickName = "Test model"; ElementData e1 = new ElementData(); e1.id = 100; e1.num = 10; playerComp.elementData.Add(e1); ElementData e2 = new ElementData(); e2.id = 101; e2.num = 10; playerComp.elementData.Add(e2); ElementData e3 = new ElementData(); e3.id = 102; e3.num = 10; playerComp.elementData.Add(e3); ElementData e4 = new ElementData(); e4.id = 103; e4.num = 00; playerComp.elementData.Add(e4); entity.AddComp(playerComp); } if (!entity.GetExistComp <CommandComponent>()) { CommandComponent c = new CommandComponent(); entity.AddComp(c); } if (!entity.GetExistComp <TransfromComponent>()) { TransfromComponent c = new TransfromComponent(); entity.AddComp(c); } if (!entity.GetExistComp <AssetComponent>()) { AssetComponent c = new AssetComponent(); c.m_assetName = "famale_01"; entity.AddComp(c); } if (!entity.GetExistComp <MoveComponent>()) { MoveComponent c = new MoveComponent(); c.pos.FromVector(new Vector3(15, 0, 0)); entity.AddComp(c); } if (!entity.GetExistComp <SkillStatusComponent>()) { SkillStatusComponent c = new SkillStatusComponent(); DataTable data = DataManager.GetData("SkillData"); for (int i = 0; i < data.TableIDs.Count; i++) { c.m_skillList.Add(new SkillData(data.TableIDs[i], i)); } entity.AddComp(c); } if (!entity.GetExistComp <CDComponent>()) { CDComponent c = new CDComponent(); entity.AddComp(c); } if (!entity.GetExistComp <CampComponent>()) { CampComponent c = new CampComponent(); c.creater = entity.ID; entity.AddComp(c); } if (!entity.GetExistComp <MoveComponent>()) { MoveComponent c = new MoveComponent(); entity.AddComp(c); } if (!entity.GetExistComp <CollisionComponent>()) { CollisionComponent c = new CollisionComponent(); c.area.areaType = AreaType.Circle; c.area.radius = 0.5f; entity.AddComp(c); } if (!entity.GetExistComp <LifeComponent>()) { LifeComponent c = new LifeComponent(); c.maxLife = playerComp.CharacterData.m_hp; c.life = playerComp.CharacterData.m_hp; entity.AddComp(c); } if (!entity.GetExistComp <BlowFlyComponent>()) { BlowFlyComponent c = new BlowFlyComponent(); entity.AddComp(c); } }
// Use this for initialization void Start() { lifeComponent = GetComponent <LifeComponent> (); }
protected override void OnUpdate() { Vector3 mp = Input.mousePosition; // RaycastHit hit; if (Boot.PVP) { if (PVPBattle.instance) { if (!PVPBattle.instance.isStep()) { cursorTxt.GetComponent <Text>().text = ""; MainCursor("UI"); return; } } } Ray ray = Camera.main.ScreenPointToRay(mp); cursorTxt.transform.position = new Vector2(mp.x + 55f, mp.y - 40f); cursorTxt.GetComponent <Text>().text = ""; for (int j = 0; j < cursor.Length; j++) { if (Physics.Raycast(ray, out hit)) { Transform objectHit = hit.transform; if (EventSystem.current.IsPointerOverGameObject()) { gs.cursor = gs.cursorNormal; return; } if (player.Length == 1) { var tr = player.tr[j]; var set = player.sett[j]; var data = player.data[j]; // Debug.Log(objectHit.tag); MainCursor(objectHit.tag); if (objectHit.tag == "Tower" || objectHit.tag == "Player_Friend") { LifeComponent life = objectHit.gameObject.GetComponent <LifeComponent>(); cursorTxt.GetComponent <Text>().text = "life:" + life.life; } if (objectHit.tag == "Map") { if (Boot.batle || Boot.PVP) { if (ground.GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity)) { cursorTxt.GetComponent <Text>().color = Color.black; int dist = (int)Vector3.Distance(hit.point, tr.position) + 1; str = dist.ToString(); if (dist > set.od) // сначала систему батле и начисление ОД { cursorTxt.GetComponent <Text>().color = Color.red; str = "X"; } cursorTxt.GetComponent <Text>().text = str; } } } if (objectHit.tag == "Player_Enemy" && tr.transform != objectHit.transform) { SettingsWeapon _ws; if (set.weaponActive == 0 && set.viewWeaponLeft) { _ws = set.viewWeaponLeft.GetComponent <SettingsWeapon>(); } else if (set.weaponActive == 1 && set.viewWeaponRight) { _ws = set.viewWeaponRight.GetComponent <SettingsWeapon>(); } else { _ws = new SettingsWeapon(); _ws.shop = 0; _ws.od = 0; _ws.shopFull = 0; _ws.cart_step = 0; } if (ground.GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity)) { cursorTxt.GetComponent <Text>().color = Color.black; int dist = (int)Vector3.Distance(objectHit.position, tr.position); int shop = _ws.shop; if (set.weaponActive == 1) { shop = _ws.shop; } // LifeComponent life = objectHit.gameObject.GetComponent<LifeComponent>(); // LifeComponent life = objectHit.GetComponent<LifeComponent>(); if (set.od >= _ws.od && shop <= _ws.shopFull && shop >= _ws.cart_step) { if (_ws.radius < dist) { cursorTxt.GetComponent <Text>().color = Color.red; str = "X"; } int pr = set.procentKillPlayer(objectHit.gameObject); cursorTxt.GetComponent <Text>().text = pr + "%"; // cursorTxt.GetComponent<Text>().text = pr + "% \n life:" + life.life; } else { cursorTxt.GetComponent <Text>().color = Color.red; str = "R"; cursorTxt.GetComponent <Text>().text = str = "R"; // cursorTxt.GetComponent<Text>().text = str + "\n life:" + life.life; } } } else if (objectHit.tag == "Enemy") { SettingsWeapon _ws; if (set.weaponActive == 0 && set.viewWeaponLeft) { _ws = set.viewWeaponLeft.GetComponent <SettingsWeapon>(); } else if (set.weaponActive == 1 && set.viewWeaponRight) { _ws = set.viewWeaponRight.GetComponent <SettingsWeapon>(); } else { _ws = new SettingsWeapon(); _ws.shop = 0; _ws.od = 0; _ws.shopFull = 0; _ws.cart_step = 0; } if (ground.GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity)) { cursorTxt.GetComponent <Text>().color = Color.black; int dist = (int)Vector3.Distance(objectHit.position, tr.position); int shop = _ws.shop; if (set.weaponActive == 1) { shop = _ws.shop; } if (set.od >= _ws.od && shop <= _ws.shopFull && shop >= _ws.cart_step) { if (_ws.radius < dist) { cursorTxt.GetComponent <Text>().color = Color.red; str = "X"; } int pr = set.procentKillEnemy(objectHit.gameObject); cursorTxt.GetComponent <Text>().text = "pr: " + pr + "%"; if (Boot.PVP) { LifeComponent life = objectHit.gameObject.GetComponent <LifeComponent>(); cursorTxt.GetComponent <Text>().text = "pr: " + pr + "% \n life:" + life.life; } } else { cursorTxt.GetComponent <Text>().color = Color.red; str = "R"; cursorTxt.GetComponent <Text>().text = str = "R"; } } } } else { MainCursor("UI"); } } } }
public void PlayerJoin(EntityBase entity) { if (!entity.GetExistComp <CommandComponent>()) { CommandComponent c = new CommandComponent(); entity.AddComp(c); } if (!entity.GetExistComp <ViewComponent>()) { ViewComponent c = new ViewComponent(); entity.AddComp(c); } if (!entity.GetExistComp <AssetComponent>()) { AssetComponent c = new AssetComponent(); c.m_assetName = "famale_01"; entity.AddComp(c); } if (!entity.GetExistComp <MoveComponent>()) { MoveComponent c = new MoveComponent(); entity.AddComp(c); } if (!entity.GetExistComp <PlayerComponent>()) { PlayerComponent c = new PlayerComponent(); entity.AddComp(c); } if (!entity.GetExistComp <SkillStatusComponent>()) { SkillStatusComponent c = new SkillStatusComponent(); DataTable data = DataManager.GetData("SkillData"); for (int i = 0; i < data.TableIDs.Count; i++) { c.m_skillList.Add(new SkillData(data.TableIDs[i], i)); } entity.AddComp(c); } if (!entity.GetExistComp <CDComponent>()) { CDComponent c = new CDComponent(); entity.AddComp(c); } if (!entity.GetExistComp <MoveComponent>()) { MoveComponent c = new MoveComponent(); entity.AddComp(c); } if (!entity.GetExistComp <CampComponent>()) { CampComponent c = new CampComponent(); entity.AddComp(c); } if (!entity.GetExistComp <CollisionComponent>()) { CollisionComponent c = new CollisionComponent(); c.area.areaType = AreaType.Circle; c.area.radius = 0.5f; entity.AddComp(c); } if (!entity.GetExistComp <LifeComponent>()) { LifeComponent c = new LifeComponent(); c.maxLife = 100; c.life = 100; entity.AddComp(c); } //预测一个输入 //TODO 放在框架中 if (entity.GetExistComp <ConnectionComponent>()) { ConnectionComponent cc = entity.GetComp <ConnectionComponent>(); cc.m_lastInputCache = new CommandComponent(); } }
public void PlayerJoin(EntityBase entity) { ConnectionComponent connectComp = entity.GetComp <ConnectionComponent>(); PlayerComponent playerComp = null; if (!entity.GetExistComp <PlayerComponent>()) { playerComp = new PlayerComponent(); entity.AddComp(playerComp); } else { playerComp = entity.GetComp <PlayerComponent>(); } //将角色ID传入游戏 playerComp.characterID = connectComp.m_session.player.characterID; playerComp.nickName = connectComp.m_session.player.playerID; ElementData e1 = new ElementData(); e1.id = 100; e1.num = 10; playerComp.elementData.Add(e1); ElementData e2 = new ElementData(); e2.id = 101; e2.num = 10; playerComp.elementData.Add(e2); ElementData e3 = new ElementData(); e3.id = 102; e3.num = 10; playerComp.elementData.Add(e3); ElementData e4 = new ElementData(); e4.id = 103; e4.num = 00; playerComp.elementData.Add(e4); if (!entity.GetExistComp <CommandComponent>()) { CommandComponent c = new CommandComponent(); entity.AddComp(c); } if (!entity.GetExistComp <TransfromComponent>()) { TransfromComponent c = new TransfromComponent(); c.pos.FromVector(new Vector3(15, 0, 0)); entity.AddComp(c); } if (!entity.GetExistComp <AssetComponent>()) { AssetComponent c = new AssetComponent(); c.m_assetName = playerComp.CharacterData.m_ModelID; entity.AddComp(c); } if (!entity.GetExistComp <MoveComponent>()) { MoveComponent c = new MoveComponent(); c.pos.FromVector(new Vector3(15, 0, 0)); entity.AddComp(c); } if (!entity.GetExistComp <SkillStatusComponent>()) { SkillStatusComponent c = new SkillStatusComponent(); DataTable data = DataManager.GetData("SkillData"); for (int i = 0; i < data.TableIDs.Count; i++) { c.m_skillList.Add(new SkillData(data.TableIDs[i], i)); } entity.AddComp(c); } if (!entity.GetExistComp <CDComponent>()) { CDComponent c = new CDComponent(); entity.AddComp(c); } if (!entity.GetExistComp <CampComponent>()) { CampComponent c = new CampComponent(); c.creater = entity.ID; entity.AddComp(c); } if (!entity.GetExistComp <MoveComponent>()) { MoveComponent c = new MoveComponent(); entity.AddComp(c); } if (!entity.GetExistComp <CollisionComponent>()) { CollisionComponent c = new CollisionComponent(); c.area.areaType = AreaType.Circle; c.area.radius = 0.5f; entity.AddComp(c); } if (!entity.GetExistComp <LifeComponent>()) { LifeComponent c = new LifeComponent(); c.maxLife = playerComp.CharacterData.m_hp; c.life = playerComp.CharacterData.m_hp; entity.AddComp(c); } if (!entity.GetExistComp <BlowFlyComponent>()) { BlowFlyComponent c = new BlowFlyComponent(); entity.AddComp(c); } //预测一个输入 //TODO 放在框架中 if (entity.GetExistComp <ConnectionComponent>()) { ConnectionComponent cc = entity.GetComp <ConnectionComponent>(); cc.m_lastInputCache = new CommandComponent(); cc.m_defaultInput = new CommandComponent(); } GameTimeComponent gtc = m_world.GetSingletonComp <GameTimeComponent>(); gtc.GameTime = 10000 * 1000; }
public void SetData(LifeComponent life, float hp) { life.currentHP = hp; life.maxHP = hp; }
protected override void OnUpdate() { gameLogicSystem.Update(); //Debug.Log("Initialize Manager Update"); if (GameVariables.InputEnabled) { //Dependency: None inputSystem.Update(); swapWeaponSystem.Update(); //Dependency: InputSystem playerTargetSystem.Update(); } //TODO REMOVE if (Input.GetKeyDown(KeyCode.Keypad1)) { //Debug.Log("Fade in..."); GlobalEvents.CameraEvents.FadeIn(); } if (Input.GetKeyDown(KeyCode.Keypad2)) { //Debug.Log("Fade out..."); GlobalEvents.CameraEvents.FadeOut(); } if (Input.GetKeyDown(KeyCode.Keypad3)) { GlobalEvents.CameraEvents.ShakeCam(0.2f, 3, 3); } if (Input.GetKeyDown(KeyCode.Keypad6)) { #if UNITY_EDITOR Debug.Log("Oh no! You killed yourself lol"); #endif LifeComponent life = EntityManager.GetComponentData <LifeComponent>(GameVariables.Player.Entity); life.Kill(); EntityManager.SetComponentData(GameVariables.Player.Entity, life); } if (Input.GetKeyDown(KeyCode.KeypadPlus)) { #if UNITY_EDITOR Debug.Log($"Giving Player all Weapons"); #endif if (!GameVariables.Player.PlayerCurrentWeapons.Contains(WeaponType.Pistol)) { GameVariables.Player.PlayerCurrentWeapons.Add(WeaponType.Pistol); } if (!GameVariables.Player.PlayerCurrentWeapons.Contains(WeaponType.Machinegun)) { GameVariables.Player.PlayerCurrentWeapons.Add(WeaponType.Machinegun); } if (!GameVariables.Player.PlayerCurrentWeapons.Contains(WeaponType.Shotgun)) { GameVariables.Player.PlayerCurrentWeapons.Add(WeaponType.Shotgun); } } }
protected override void OnUpdate() { //Get Physic World PhysicsWorld physicsWorld = buildPhysicsWorld.PhysicsWorld; //Create ECB var entityCommandBuffer = endSimulationEntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent(); //Create parallel writer NativeQueue <BulletInfo> .ParallelWriter events = bulletEvents.AsParallelWriter(); //Get all enemy existing ComponentDataContainer <EnemyTag> enemies = new ComponentDataContainer <EnemyTag> { Components = GetComponentDataFromEntity <EnemyTag>(true) }; //Get all entities with life ComponentDataContainer <LifeComponent> entitiesLife = new ComponentDataContainer <LifeComponent> { Components = GetComponentDataFromEntity <LifeComponent>(true) }; // ComponentDataContainer <DropChanceComponent> dropChance = new ComponentDataContainer <DropChanceComponent> { Components = GetComponentDataFromEntity <DropChanceComponent>(true) }; //Get Player entity Entity player = GameVariables.Player.Entity; JobHandle job = Entities.ForEach((Entity entity, int entityInQueryIndex, ref DamageProjectile projectile, ref Translation translation, in Rotation rotation, in BulletCollider bulletCollider, in BulletPreviousPositionData previousPosition) => { //Create Personal Filter for each Bullet CollisionFilter filter = new CollisionFilter { BelongsTo = bulletCollider.BelongsTo.Value, CollidesWith = bulletCollider.CollidesWith.Value, GroupIndex = bulletCollider.GroupIndex }; //Find direction float3 direction = translation.Value - previousPosition.Value; direction = math.normalizesafe(direction); //Find Vector to add float3 offset = default; float offsetRad = math.radians(90f); float cos = math.cos(offsetRad); float sin = math.sin(offsetRad); offset.x = direction.x * cos - direction.z * sin; offset.z = direction.x * sin + direction.z * cos; offset *= projectile.Radius; //Create Ray Inputs RaycastInput middleRayCast = GetRayCastInput(filter, translation.Value, previousPosition.Value, float3.zero); RaycastInput rightRayCast = GetRayCastInput(filter, translation.Value, previousPosition.Value, offset); RaycastInput leftRayCast = GetRayCastInput(filter, translation.Value, previousPosition.Value, -offset); //Adding a negative radius bool hitDetected = false; Entity hitEntity = Entity.Null; RaycastHit hit = default; float3 hitPosition = default; //Try first RayCast if (physicsWorld.CollisionWorld.CastRay(middleRayCast, out RaycastHit middleRayCastHit)) { hitDetected = true; hit = middleRayCastHit; hitPosition = float3.zero; //Get Hit Entity hitEntity = physicsWorld.Bodies[middleRayCastHit.RigidBodyIndex].Entity; } else if (physicsWorld.CollisionWorld.CastRay(rightRayCast, out RaycastHit rightRayCastHit)) { hitDetected = true; hit = rightRayCastHit; hitPosition = -offset; //Get Hit Entity hitEntity = physicsWorld.Bodies[rightRayCastHit.RigidBodyIndex].Entity; } //Try second RayCast (Only if first one didnt hit) else if (physicsWorld.CollisionWorld.CastRay(leftRayCast, out RaycastHit leftRayCastHit)) { hitDetected = true; hit = leftRayCastHit; hitPosition = offset; //Get Hit Entity hitEntity = physicsWorld.Bodies[leftRayCastHit.RigidBodyIndex].Entity; } //Make sure theres a collision if (!hitDetected) { return; } //Make sure an Entity was found if (hitEntity == Entity.Null) { return; } //Make sure collision hasn't been found before //TODO //Treat Collision //Collision = Wall until proven opposite BulletInfo.BulletCollisionType collisionType = BulletInfo.BulletCollisionType.ON_WALL; //Look if HitEntity is Player's if (hitEntity == player) { collisionType = BulletInfo.BulletCollisionType.ON_PLAYER; } //Look if HitEntity is an enemy else if (enemies.Components.HasComponent(hitEntity)) { collisionType = BulletInfo.BulletCollisionType.ON_ENEMY; } bool shouldBulletBeDestroyed = true; //Damage entity if (collisionType != BulletInfo.BulletCollisionType.ON_WALL) { //Make sure HitEntity has LifeComponent if (entitiesLife.Components.HasComponent(hitEntity)) { //Make sure HitEntity has LifeComponent if (entitiesLife.Components.HasComponent(hitEntity)) { //Get LifeComponent of this entity LifeComponent life = entitiesLife.Components[hitEntity]; //Decrease life if (player == hitEntity) { shouldBulletBeDestroyed = life.DecrementLifeWithInvincibility(); } else if (entitiesLife.Components[hitEntity].Life.Value <= 0) { shouldBulletBeDestroyed = false; } else { life.DecrementLife(); } //Set Back entityCommandBuffer.SetComponent(entityInQueryIndex, hitEntity, life); } } } //Destroy bullet if (shouldBulletBeDestroyed) { entityCommandBuffer.DestroyEntity(entityInQueryIndex, entity); events.Enqueue(new BulletInfo { HitEntity = hitEntity, ProjectileType = projectile.Type, CollisionType = collisionType, HitPosition = hit.Position + hitPosition, HitRotation = rotation.Value }); } }).ScheduleParallel(Dependency);
private void Awake() { lifeComponent = GetComponent <LifeComponent>(); lifeComponent.EventLifeChange += ChangeVisual; }
private static float PlayerLifePourcent(LifeComponent lifeComponent) { return((lifeComponent.Life.Value * 100) / lifeComponent.Life.Max); }
protected override void OnUpdate() { foreach (WeaponInfo info in EventsHolder.WeaponEvents) { if (info.Parent != GameVariables.Player.Entity) { continue; } switch (info.EventType) { case WeaponInfo.WeaponEventType.ON_SHOOT: UIManager.OnShoot(); break; case WeaponInfo.WeaponEventType.ON_RELOAD: UIManager.OnReload(info.AmountBulletsInMagazine); break; case WeaponInfo.WeaponEventType.ON_SWAP: UIManager.SetWeaponType(info.WeaponType); break; } } foreach (BulletInfo info in EventsHolder.BulletsEvents) { if (info.HitEntity != GameVariables.Player.Entity) { return; } UIManager.OnPlayerHit(); } if (!GameVariables.UI.GunName) { return; } if (GameVariables.Player.PlayerWeaponEntities.ContainsKey(GameVariables.Player.CurrentWeaponHeld)) { gunComponent = EntityManager.GetComponentData <GunComponent>(GameVariables.Player.PlayerWeaponEntities[GameVariables.Player.CurrentWeaponHeld]); } lifeComponent = EntityManager.GetComponentData <LifeComponent>(GameVariables.Player.Entity); switch (gunComponent.WeaponType) { case WeaponType.Pistol: GameVariables.UI.ShotgunImage.enabled = false; GameVariables.UI.PistolImage.enabled = true; break; case WeaponType.Shotgun: GameVariables.UI.ShotgunImage.enabled = true; GameVariables.UI.PistolImage.enabled = false; break; } GameVariables.UI.NbBulletInMagazine.text = gunComponent.CurrentAmountBulletInMagazine.ToString(); GameVariables.UI.NbBulletOnPlayer.text = gunComponent.CurrentAmountBulletOnPlayer.ToString(); GameVariables.UI.lifeRect.sizeDelta = new Vector2(PlayerUiWidth(PlayerLifePourcent(lifeComponent), GameVariables.UI.lifeBgRect.rect.size.x), GameVariables.UI.lifeBgRect.sizeDelta.y); }
protected void Awake() { enabled = false; Life = this.SearchComponent <LifeComponent>(); }
public void InitializeText(LifeComponent lifeComponent) { this.lifeComponent = lifeComponent; playerCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); }
public void InitializeHPBar(LifeComponent lifeComponent) { this.lifeComponent = lifeComponent; gameObject.SetActive(showed); }
private GameObject SpawnNpc(Transform[] fightersgroup) { GameObject temp = null; int teamnum = 0; for (int i = 0; i < _characters.Length; i++) { if (_characters[i] == fightersgroup) { temp = BasicLib.InstantiatePrefabGmbjct("mobs/npc", MyColorLib.teams[i].transform); teamnum = i; break; } } LifeComponent life = temp.SearchComponent <LifeComponent>(); AI aivars = temp.SearchComponent <AI>(); BaseCharacterControl vars = temp.GetCharacter(); MoveComponent MoveComponent = temp.SearchComponent <MoveComponent>(); //MoveComponent.speed = 10f; MoveComponent.SetPosition(_centreSpawns[teamnum] + new Vector3(Random.Range(-10f, 10f), Random.Range(-10f, 10f))); aivars.SearchComponent <MoveAround_ChillMode>().CentrePosition = Vector3.zero; /* * foreach (Transform[] otherteam in fighters) * { * if (otherteam != fightersgroup) * { * rules.addToCandoAndToOthers(otherteam, MoveComponent.transform, true, true); * } * } */ int rand = Random.Range(0, 5); if (rand == 0) { aivars.AddAttacks(new int[] { WeaponsStaticClass.fire }); temp.AddComponent <AttackFromDistance_AttackMode>(); } else if (rand == 1) { aivars.AddAttacks(new int[] { WeaponsStaticClass.ball }); temp.AddComponent <BallCharge_AttackMode>(); } else if (rand == 2) { aivars.AddAttacks(new int[] { WeaponsStaticClass.spray }); temp.AddComponent <AttackFromDistance_AttackMode>(); } else if (rand == 3) { aivars.AddAttacks(new int[] { WeaponsStaticClass.ball }); BallChargeAttack ball = temp.SearchComponent <BallChargeAttack>(); ball.Reach = 30f; ball.MaxSize = 1f; ball.Speed = 60f; temp.AddComponent <BallCharge_AttackMode>(); } else if (rand == 4) { aivars.AddAttacks(WeaponsStaticClass.shield).SearchComponent <Shield>().SetUpAI(); } return(temp); }
private void Start() { m_SteerBehavior = GetComponent <SteerComponent>(); m_LifeComponent = GetComponent <LifeComponent>(); m_FSM = new AgentStateMachine(this); }