public void Dispose() { Toolbox.Get <ProcessingSignals>().Remove(this); ProcessingUpdate.Default.Remove(this); OnDispose(); }
protected virtual void GetKilled() { actor.selfTransform.ChangeLayersRecursively("Dead"); var rigid = Get <Rigidbody2D>(); rigid.AddForceAtPosition(new Vector2(Get <DataMove>().face, 4) * 15, actor.selfTransform.position); // rigid.constraints = RigidbodyConstraints2D.None; var rend = actor.selfTransform.GetChild(0).GetComponent <SpriteRenderer>(); actor.selfTransform.GetChild(0).DORotate(new Vector3(0, 0, 640), 1); rend.sortingOrder = 3; rend.color = new Color(0.65f, 0.65f, 0.65f, 1); Toolbox.Get <FactoryFx>() .SpawnBlood(actor.selfTransform.position + new Vector3(Random.Range(-0.2f, 0.2f), Random.Range(-0.2f, 0.2f))); actor.tags.Add(Tag.StateDead); actor.HandleDestroyGO(); actor.OnDisable(); if (actor.tags.Contain(Tag.GroupEnemies)) { ProcessingSignals.Default.Send(new SignalChangeScore()); ProcessingSignals.Default.Send(new SignalKilled { tag = Tag.GroupEnemies }); } }
public void SpawnBlood(Vector3 pos) { var blood = this.Populate(Pool.Entities, dataBlood.prefab); blood.GetComponent <SpriteRenderer>().sprite = dataBlood.sprites.Random(); blood.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1); blood.transform.position = new Vector3(pos.x, pos.y, -0.1f); blood.localScale = new Vector3(0, 0, 0); blood.DOScale(Random.Range(1, 2f), 0.3f).SetEase(Ease.OutSine); Timer.Add(Random.Range(2, 5), () => { var rend = blood.GetComponent <SpriteRenderer>(); var a = 1.0f; DOTween.To(() => a, x => a = x, 0.0f, 1.0f).OnUpdate(() => { rend.color = rend.color.SetColorAlpha(a); }); Timer.Add(1.0f, () => { Toolbox.Get <ProcessingGoPool>().Despawn(Pool.Entities, blood.gameObject); }); }); }
public void Setup(IComponent b, IEntity a) { var type = b.GetType(); CachedType o; var isCached = cached.TryGetValue(type, out o); if (!isCached) { o = new CachedType(); var objectFields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); var length = objectFields.Length; cached.Add(type, o); for (var i = 0; i < length; i++) { var myFieldInfo = objectFields[i]; var attribute = Attribute.GetCustomAttribute(objectFields[i], typeof(BindAttribute)) as BindAttribute; if (attribute != null) { var fieldType = myFieldInfo.FieldType; switch (attribute.bindType) { case 0: myFieldInfo.SetValue(b, a.Get(fieldType)); o.cachedBindFields.Add(myFieldInfo); break; case 1: myFieldInfo.SetValue(b, Toolbox.Get(fieldType)); o.cachedToolboxFields.Add(myFieldInfo); break; case 2: var actor = a as Actor; myFieldInfo.SetValue(b, actor != null ? actor.GetComponentInChildren(fieldType) : a.GetTransform().GetComponentInChildren(fieldType)); o.cachedFromObjFields.Add(myFieldInfo); break; case 3: var blueprint = a.Get <DataBlueprint>().blueprint; myFieldInfo.SetValue(b, blueprint.Get(fieldType)); o.cachedFromBlueprintFields.Add(myFieldInfo); break; } } } } else { o.Bind(b, a); o.GetFromToolbox(b); o.GetFromObject(b, a); o.GetFromBlueprint(b, a); } }
public static void To(int id) { var processing = Toolbox.Get <ProcessingSceneLoad>(); var name = processing.GetFromList(id); Toolbox.Instance.StartCoroutine(processing._Load(name)); }
public void HandleSignal(SignalTriggerEnter arg) { if (!arg.other.HasTag(Tag.ColliderHit)) { return; } if (actor.tags.Contain(Tag.StateGod)) { return; } // check enemy var otherActor = arg.other.GetComponentInParent <Actor>(); if (otherActor != null && otherActor.tags.Contain(Tag.GroupEnemies)) { otherActor.Get <BehaviorGetDamage>().HandleDamage(100); } HandleDamage(1); if (arg.other.HasTag(Tag.ObjectBullet)) { Toolbox.Get <FactorySounds>().Spawn(Tag.SoundShootHit); Toolbox.Get <ProcessingGoPool>().Despawn(Pool.Projectiles, arg.other.gameObject); } }
private void Awake() { processingConsole = Toolbox.Get <ProcessingConsole>(); canvasGroup = GetComponent <CanvasGroup>(); canvasGroup.alpha = 0; }
void HandleSpawnPlayer() { var go = Toolbox.Get <FactorySpawner>().SpawnPlayer(); go.position = Toolbox.Get <DataCryoshockGameSession>().spawners[0].selfTransform.position; go.GetComponent <Actor>().tags.Add(Tag.StateBlockMove); Timer.Add(0.8f, () => { go.GetComponent <Actor>().tags.Remove(Tag.StateBlockMove); }); }
public static T Populate <T>(this object o, int poolID, int prefabID, string parentID, Vector3 startPosition = default(Vector3), Quaternion startRotation = default(Quaternion)) where T : class { var parent = Toolbox.Get <ProcessingScene>().Get(parentID); var tr = o.Populate(poolID, prefabID, startPosition, startRotation, parent); return(tr.GetComponent <T>()); }
public void GetFromToolbox(Behavior behavior) { for (var i = 0; i < cachedToolboxFields.Count; i++) { var myFieldInfo = cachedToolboxFields[i]; var fieldType = myFieldInfo.FieldType; myFieldInfo.SetValue(behavior, Toolbox.Get(fieldType)); } }
public static void Kill(Timer obj) { if (obj == null) { return; } obj.Stop(); Toolbox.Get <ProcessingPools>().Despawn(obj); }
public static void AddTo(object awakeble) { var mngUpdate = Toolbox.Get <ManagerActors>(); mngUpdate.actors.Add(awakeble as ActorBase); if (awakeble is IAwake) { (awakeble as IAwake).OnAwake(); } }
public static void Setup(object b) { var type = b.GetType(); CachedType o; bool isCached = cached.TryGetValue(type, out o); if (!isCached) { o = new CachedType(); var objectFields = type.GetFields(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); int length = objectFields.Length; cached.Add(type, o); for (int i = 0; i < length; i++) { var myFieldInfo = objectFields[i]; var attribute = Attribute.GetCustomAttribute(objectFields[i], typeof(BindAttribute)) as BindAttribute; if (attribute == null) { continue; } var fieldType = myFieldInfo.FieldType; switch (attribute.bindType) { case 0: break; case 1: myFieldInfo.SetValue(b, Toolbox.Get(fieldType)); o.cachedToolboxFields.Add(myFieldInfo); break; case 2: break; case 3: break; } } } else { o.GetFromToolbox(b); } }
private void OnEnable() { fieldInput.onSubmit.AddListener(AddToConsole); fieldInput.onValueChanged.AddListener(ChangeText); Toolbox.Get <ProcessingUpdate>().Add(this); Timer.Add(UnityEngine.Time.deltaTime, () => EventSystem.current.SetSelectedGameObject(fieldInput.gameObject)); fieldInput.caretPosition = 1; tickDebug = 0.0f; RenderDebug(); StartCoroutine(_ColorLine()); }
protected virtual void HandleReturnToPool() { var processingPool = Toolbox.Get <ProcessingGoPool>(); if (timeDestroyDelay > 0) { Timer.Add(timeDestroyDelay, () => processingPool.Despawn(pool, gameObject)); } else { processingPool.Despawn(pool, gameObject); } }
protected override void Setup() { Toolbox.Get <DataCryoshockGameSession>().score = 0; Toolbox.Add <ProcessingVoice>(); Toolbox.Add <ProcessingSaveGroups>(); Toolbox.Add <ProcessingCameraShake>(); Toolbox.Add <ProcessingParallax>(); Toolbox.Add <ProcessingScore>(); Toolbox.Add <ProcessingGame>(); Toolbox.Get <ProcessingSceneLoad>().sceneClosing = CloseScene; }
public static Transform Populate(this object o, Pool poolID, GameObject prefab, Vector3 startPosition = default(Vector3), Quaternion startRotation = default(Quaternion), Transform parent = null, WorldParenters parenters = WorldParenters.Level) { var parenter = parent ?? Toolbox.Get <ProcessingScene>().Get(parenters); var go = poolID == Pool.None ? Object.Instantiate(prefab, startPosition, startRotation, parenter).transform : ProcessingGoPool.HandleSpawn(poolID, prefab, startPosition, startRotation, parenter).transform; go.position = startPosition; return(go); }
void HandleEnemies(Actor a) { if (!a.tags.Contain(Tag.GroupEnemies)) { return; } var tr = Toolbox.Get <DataCryoshockGameSession>().spawners[0]; Toolbox.Get <FactorySounds>().Spawn(Tag.SoundAlarm, 1); a.selfTransform.position = tr.transform.position; a.tags.Add(Tag.StateRage); a.tags.Add(Tag.StateBlockMove); Timer.Add(0.5f, () => a.tags.Remove(Tag.StateBlockMove)); }
public static T Get <T>() { object resolve = null; var actors = Toolbox.Get <ManagerActors>().actors; foreach (var actor in actors) { if (actor is T) { resolve = actor; } } return((T)resolve); }
private void RenderDebug() { fStr.Length = 0; fStr .AppendFormat("Time : {0} ms GPU memory : {1} Sys Memory : {2}\n", Time.DeltaTime, SystemInfo.graphicsMemorySize, SystemInfo.systemMemorySize) .AppendFormat("TotalAllocatedMemory : {0}mb TotalReservedMemory : {1}mb TotalUnusedReservedMemory : {2}mb\n", Profiler.GetTotalAllocatedMemoryLong() / 1048576, Profiler.GetTotalReservedMemoryLong() / 1048576, Profiler.GetTotalUnusedReservedMemoryLong() / 1048576) .AppendFormat("Actors : {0} Ticks : {1}", Toolbox.Get <ProcessingEntities>().listActors.Count, Toolbox.Get <ProcessingUpdate>().GetTicksCount()); labelDebug.text = fStr.ToString(); }
void CheckNoWeapon() { if (groupWeapon.length == 0) { Timer.Add(10, () => { if (groupPlayers.length == 0) { return; } Toolbox.Get <FactorySpawner>().SpawnWeapon(groupSpawnWeapon.actors.ReturnRandom().selfTransform.position, groupPlayers.actors[0].Get <DataCurrentWeapon>().weapon); }); } }
public void HandleSignal(SignalDamage arg) { if (Random.value > 0.6f) { Toolbox.Get <FactoryFx>().SpawnBlood(actor.selfTransform.position + new Vector3(Random.Range(-0.2f, 0.2f), Random.Range(-0.2f, 0.2f))); } var dataView = actor.Get <DataView>(); dataView.matPropBlock.SetFloat("_Blink", 1); dataView.SetPropertyBlock(); Timer.Add(0.1f, () => { dataView.matPropBlock.SetFloat("_Blink", 0); dataView.SetPropertyBlock(); }); }
public void Populate() { var procPool = Toolbox.Get <ProcessingGoPool>(); var poolStash = procPool.pools[(int)pool]; poolStash.RegisterObject(prefab); for (var i = 0; i < createdObjs.Count; i++) { poolStash.AddToPool(createdObjs[i], prefab); } // procPool.pools[pool.GetHashCode()].AddToPool(); //Toolbox.Get<ProcessingPool>().AddPool() }
public void Shoot(Rigidbody2D rig, float side, Transform muzzle) { rig.AddForceAtPosition(new Vector2(-side * returnForce, 0), rig.transform.position); ProcessingSignals.Default.Send(new SignalCameraShake { strength = shakeForce }); Toolbox.Get <FactorySounds>().Spawn(soundsTag); for (var i = 0; i < amountPerShot; i++) { var bullet = this.Populate(Pool.Projectiles, prefabBullet); bullet.position = muzzle.position; var bulletRig = bullet.GetComponent <Rigidbody2D>(); bulletRig.drag = Random.Range(speedDrag.x, speedDrag.y); bulletRig.AddForce(new Vector2(side * speedIntial, Random.Range(-1f, 1f) * spread)); bullet.GetComponent <ComponentBullet>().timerDestroy = timeBeforeDestroy; } }
public static void RemoveFrom(object updateble) { var mngUpdate = Toolbox.Get <ManagerUpdate>(); if (updateble is ITick) { mngUpdate.ticks.Remove(updateble as ITick); } if (updateble is ITickFixed) { mngUpdate.ticksFixes.Remove(updateble as ITickFixed); } if (updateble is ITickLate) { mngUpdate.ticksLate.Remove(updateble as ITickLate); } }
private void OnDisable() { if (Toolbox.isQuittingOrChangingScene()) { return; } Toolbox.Get <ProcessingUpdate>().Remove(this); fieldInput.text = string.Empty; fieldInput.onSubmit.RemoveListener(AddToConsole); fieldInput.onValueChanged.RemoveListener(ChangeText); if (EventSystem.current != null) { EventSystem.current.SetSelectedGameObject(null); } }
public static void AddTo(object updateble) { //Debug.Log(updateble.GetType()); var mngUpdate = Toolbox.Get <ManagerUpdate>(); if (updateble is ITick) { mngUpdate.ticks.Add(updateble as ITick); } if (updateble is ITickFixed) { mngUpdate.ticksFixes.Add(updateble as ITickFixed); } if (updateble is ITickLate) { mngUpdate.ticksLate.Add(updateble as ITickLate); } }
void HandleSpawn() { wave++; if (wave % 10 == 0) { waveLevel = Mathf.Min(waveLevel += 1, 2); } var amount = spawnMobs[waveLevel]; var factory = Toolbox.Get <FactorySpawner>(); for (int i = 0; i < amount; i++) { Timer.Add(i * 0.8f, () => { var go = factory.Spawn(0); go.position = Toolbox.Get <DataCryoshockGameSession>().spawners[0].selfTransform.position; }); } Timer.Add(spawnWait[waveLevel], HandleSpawn); }
public static void To(string name) { var processing = Toolbox.Get <ProcessingSceneLoad>(); Toolbox.Instance.StartCoroutine(processing._Load(name)); }
public static void RemoveFrom(object awakeble) { var mngUpdate = Toolbox.Get <ManagerActors>(); mngUpdate.actors.Remove(awakeble as ActorBase); }