protected override void BrainInitialisation() { hp = configScriptable.bossHp; damage = configScriptable.bossDamage; speed = configScriptable.bossSpeed; bulletSpeed = configScriptable.bossBulletSpeed; damageDealed = false; brain = new Brain(true); Chase chase = new Chase(2f, transform, AI.GetPlayer(), speed * 2); RandomMove randomMove = new RandomMove(1f, transform, speed); ShootAtPosition shoot = new ShootAtPosition(.2f, transform, AI.GetPlayer(), false, bulletSpeed, damage); MultiShot multiShoot = new MultiShot(.2f, transform, AI.GetPlayer(), damage, bulletSpeed); AIWait aIWait = new AIWait(1f); brain.AddAIMechanic(chase); brain.AddAIMechanic(aIWait); brain.AddAIMechanic(multiShoot); brain.AddAIMechanic(aIWait); brain.AddAIMechanic(shoot); brain.AddAIMechanic(shoot); brain.AddAIMechanic(shoot); brain.AddAIMechanic(aIWait); brain.AddAIMechanic(randomMove); brain.ChooseState(); coroutine = Wait(brain.GetCooldown()); StartCoroutine(coroutine); }
private void TestGenerateEnemy() { for (int i = 0; i < enemyIndexs.Count; i++) { GameObject obj = null; obj = Common.Generate(DataController.prefabPath_Character + enemyIndexs[i], transEnemy); obj.transform.position = DataController.instance.bossPos + new Vector3(3, 0, 0); obj.transform.DOMove(DataController.instance.bossPos, 0.5f); // CharacterInfo info = obj.GetComponent <CharacterInfo>(); info.Init(enemyIndexs[i], true); // CardInfo cardInfo = info.cardInfo; cardInfo.myTag = Tag.Enemy; cardInfo.isEnemy = false; cardInfo.Hp = GameManager.BackCardHp(info.myIndex); cardInfo.Atk = GameManager.BackCardAtk(info.myIndex); cardInfo.myName = "敌方->" + (int)info.myIndex; cardInfo.SetInit(); //转向面向主角 info.AnimationObj.localScale = new Vector3(-1, 1, 1); showEnemy.Add(cardInfo); // RandomMove erMove = obj.AddComponent <RandomMove>(); float radius = 2f; erMove.center = new Vector3(DataController.instance.bossPos.x, 0, DataController.instance.playerPos.z) - new Vector3(radius, 0); erMove.radius = radius; erMove.timeRandom = new Vector2(2, 5); erMove.Init(); } }
private static void Create() { DontDestroyOnLoad(new GameObject("LoadTest").AddComponent <LoadTest>().gameObject); //Example //WarmUp ShaderVariants //AssetBundleLoader.LoadAsset("Example/Res/Shaders/Scene01ShaderVariants.shadervariants", (ShaderVariantCollection shadervariants) => //{ // shadervariants.WarmUp(); //}); //Load a scene AssetBundleLoader.LoadScene("Example/Res/Scenes/Scene01/Scene01", (Scene scene01) => { if (scene01 != default) { //Load an asset whith extension AssetBundleLoader.LoadAsset("Example/Res/Prefabs/Sphere.prefab", (GameObject sphere) => { for (int i = 0; i < 20; i++) { GameObject obj = Instantiate(sphere); RandomMove randomMove = obj.GetComponent <RandomMove>(); randomMove.during = Random.Range(0.03f, 0.18f); } }); } }, LoadSceneMode.Additive); }
public override void DoNextAction(GameContext gameContext) { IAction action = null; var ghostsTargeted = gameContext.Busters.Select(b => b.GhostTarget); if (ghostsTargeted != null && ghostsTargeted.Any()) { var ghost = ghostsTargeted.OrderByDescending(g => g.State).FirstOrDefault(); var dist = ghost.Position.GetDist(Buster.Position); if (dist < 1760 && dist > 900) { action = new Bust(ghost.Id); } else { if (dist < 900) { action = new Move(ghost.Position.X + 50, ghost.Position.Y); } else { action = new Move(ghost.Position); } } } else { action = new RandomMove(); } action.Do("support"); }
private void MakeMove(GameObject enemy, MoveManager moveManager) { Move move = new RandomMove(enemy.transform, enemy.GetComponent <Animator>(), new IntValue(1)); moveManager.Add(MoveState.Main, enemy, move); moveManager.Add(MoveState.Atack, enemy, move); }
// Use this for initialization void Start() { maxHealth = InitialMaxHealth; UpdateHealth(); spriteRenderer = GetComponent <SpriteRenderer>(); randomMove = GetComponent <RandomMove>(); }
// Use this for initialization void Start() { _randommove = GetComponent <RandomMove>(); _track = GetComponent <Track>(); _attack = GetComponent <Enemy_Attack>(); _player = GameObject.FindWithTag("Player").transform; Particle_hit = GetComponentInChildren <ParticleSystem>(); }
public override void DoNextAction(GameContext gameContext) { var comment = ""; IAction action = null; if (Buster.StunAvailableIn <= 0) { var a = gameContext.OppositeBusters.FirstOrDefault(b => b.Position.GetDist(Buster.Position) < 1760); if (a != null && a.StunFor < 3) { action = new Stun(a); Buster.StunAvailableIn = 20; } } if (action == null && gameContext.Ghosts.Any(g => g.Position.GetDist(Buster.Position) < 2200)) { comment = "ghost to catch"; Ghost target; if (Buster.GhostTarget != null && gameContext.Ghosts.Select(g => g.Id).Contains(Buster.GhostTarget.Id)) { target = Buster.GhostTarget; } else { target = gameContext.Ghosts .Where(g => g.Position.GetDist(Buster.Position) < 2200 && gameContext.MyBusters.Where(b => b.GhostTarget?.Id == g.Id).Count() <= g.Value) .OrderBy(g => Buster.Position.GetDist(g.Position)) .FirstOrDefault(); } Buster.GhostTarget = target; if (target != null) { var dist = Buster.Position.GetDist(target.Position); if (dist < 1760 && dist > 900) { action = new Bust(target.Id); } else { if (dist < 900) { action = new Move(target.Position.X + 50, target.Position.Y); } else { action = new Move(target.Position); } } } } if (action == null) { comment = "no ghost"; action = new RandomMove(); } action.Do(comment); }
// Use to process your families. protected override void onProcess(int familiesUpdateCount) { foreach (GameObject go in _randomMovingGO) { RandomMove rm = go.GetComponent <RandomMove>(); if (rm.target.Equals(go.transform.position)) { rm.target = new Vector3(Random.Range(-_board.size.x / 2, _board.size.x / 2), Random.Range(-_board.size.y / 2, _board.size.y / 2), 0); } else { go.transform.position = Vector3.MoveTowards(go.transform.position, rm.target, go.GetComponent <Move>().speed *Time.deltaTime); } } }
// Use to process your families. protected override void onProcess(int familiesUpdateCount) { foreach (GameObject go in _controllableGO) { RandomMove randomMoveAvg = go.GetComponent <RandomMove> (); float time; float reloadProgress; bool left; time = randomMoveAvg.reloadTimeLeft; randomMoveAvg.reloadProgressLeft += Time.deltaTime; reloadProgress = randomMoveAvg.reloadProgressLeft; left = randomMoveAvg.left; if (reloadProgress >= time) { if (randomMoveAvg != null) { randomMoveAvg.randomRangeLeft(); } } Transform tr = go.GetComponent <Transform> (); Move mv = go.GetComponent <Move> (); Vector3 movement = Vector3.zero; if (left) { movement += Vector3.left; } else { movement += Vector3.right; } tr.position += movement * mv.vitesse * mv.coefd * mv.coefv * Time.deltaTime; } }
// Use to process your families. protected override void onProcess(int familiesUpdateCount) { //Faire des randoms move foreach (GameObject go in _controllableGO) { RandomMove randomMoveAvg = go.GetComponent <RandomMove> (); float time; float reloadProgress; bool up; time = randomMoveAvg.reloadTimeUp; randomMoveAvg.reloadProgressUp += Time.deltaTime; reloadProgress = randomMoveAvg.reloadProgressUp; up = randomMoveAvg.up; if (reloadProgress >= time) { if (randomMoveAvg != null) { randomMoveAvg.randomRangeUp(); } } Transform tr = go.GetComponent <Transform> (); Move mv = go.GetComponent <Move> (); Vector3 movement = Vector3.zero; if (up) { movement += Vector3.up * 0.2f; } else { movement += Vector3.down * 0.2f; } tr.position += movement * mv.vitesse * mv.coefd * mv.coefv * Time.deltaTime; } }
protected override void BrainInitialisation() { hp = configScriptable.flyerHp; damage = configScriptable.flyerDamage; speed = configScriptable.flyerSpeed; bulletSpeed = configScriptable.flyerBulletSpeed; brain = new Brain(true); RandomMove randomMove = new RandomMove(1f, transform, speed); ShootAtPosition shoot = new ShootAtPosition(1f, transform, AI.GetPlayer(), false, bulletSpeed, damage); brain.AddAIMechanic(randomMove); brain.AddAIMechanic(shoot); brain.ChooseState(); coroutine = Wait(brain.GetCooldown()); StartCoroutine(coroutine); }
void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); randomMove = GetComponent <RandomMove>(); physicsMove = GetComponent <PhysicsMove>(); }