/*------------------------------------------------------------------*\ |* IMPACTS \*------------------------------------------------------------------*/ private void CreateImpact(GameObject go, Vector3 position, Quaternion direction) { var impact = Object.Instantiate(go, position, direction); impact.transform.parent = InitializationGameObject; FunctionDelay.Create(() => Object.Destroy(impact), 2.5f); }
public void Attack() { Engaging.HardLookAtTarget(); Entity.Animation.SetAttackAnimation(); FunctionDelay.Create(AttackCallback, Engaging.AttackDelay); }
public void SetAttackAnimation() { Animator.SetBool(ATTACK, true); Entity.Agent.speed = 0; Entity.Agent.acceleration = 1000f; FunctionDelay.Create(AttackCallback, 1.5f); }
private void DestroyStructure() { FadeOutFire(); entity.transform.Find("HitBox").gameObject.SetActive(false); DecreaseCompletionState(10f, 6f); FunctionDelay.Create(() => DecreaseCompletionState(6f, 7f), 1f); }
private void CreateCharacter(Entity built, Entity builder) { var path = $"Prefabs/Entities/Characters/{built.Meta.Class}"; var spawn = builder.extensions.Find("Spawn").transform; var go = Resources.Load(path) as GameObject; var instance = Instantiate(go, Helpers.SetZ(spawn.position, spawn.position.z + Random.Range(-2, 2)), Helpers.RandomRotation() ); var playerType = builder.Owner.playerType; instance.GetComponent <OwnerComponent>().playerType = playerType; instance.transform.parent = InitializationGameObject; var entity = instance.GetComponent <Entity>(); FunctionDelay.Create(() => { PlayerController.Instance.PayPrice(entity); entity.SetDestination(entity.Position + Vector3.forward); PlayerController.Instance.Message = $"New {built.Meta.Class} ready !"; PlayerController.Instance.Population++; builder.Actions.isBUilding = false; }, .1f ); }
public void SetDamagesAnimation() { Animator.SetBool(DAMAGES, true); Entity.Agent.speed = 0; Entity.Agent.acceleration = 1000f; FunctionDelay.Create(DamagesCallback, 0.1f); }
public void Attack() { Entity.Engaging.HardLookAtTarget(); Entity.Animation.SetAttackAnimation(); FunctionDelay.Create(AttackCallback, .2f); FunctionDelay.Create(() => Entity.Animation.SetIdleAnimation(), .75f); }
/*------------------------------------------------------------------*\ |* FX \*------------------------------------------------------------------*/ private GameObject CreateFX(GameObject go, Vector3 position, float scale, float duration) { var fx = Object.Instantiate(go, position, Quaternion.identity); fx.transform.localScale = Vector3.one * scale; fx.transform.parent = InitializationGameObject; FunctionDelay.Create(() => Object.Destroy(fx), duration); return(fx); }
public void Update() { if (!Entity.Engaging.IsTargetAlive() || !Entity.Engaging.IsTargetInRange()) { FunctionDelay.Create( () => { Entity.ClearTarget(); Entity.ClearDestination(); }, .4f ); } }
private void Start() { foreach (Transform child in transform) { child.gameObject.SetActive(true); } FunctionDelay.Create(() => { transform.Find("Mask").transform.position = new Vector3(0, -5, 0); }, .5f ); }
public virtual void Interact() { if (IsInteracting || !Target || Target.disabled) { return; } IsInteracting = true; entity.Animation.SetAttackAnimation(); entity.Movable.Stop(); entity.HardLookAtTarget(); FunctionDelay.Create(() => IsInteracting = false, CoolDown); }
/*------------------------------------------------------------------*\ |* IState IMPLEMENTATION \*------------------------------------------------------------------*/ public void Update() { if (!entity.Interaction.TargetFinished() && entity.Interaction.TargetInRange()) { entity.Interaction.Interact(); } else { FunctionDelay.Create( () => { entity.ClearTarget(); entity.ClearDestination(); }, .4f ); } }
private void DisableComponents(bool soft) { if (State) { State.Current.OnExit(); } // State = null; Selectable = null; Awareness = null; if (soft) { FunctionDelay.Create(DisablePhysics, .5f); } else { DisablePhysics(); } }
public void Callback() { if (cooldown) { return; } cooldown = true; FunctionDelay.Create(() => cooldown = false, .3f); if (PlayerController.Instance.CheckPrice(Built)) { if (Built.Meta.IsStructure) { BuildingSpawner.Instance.SetCurrent(Built, Builder); } else { CharacterSpawner.Instance.StartTraining(Built, Builder); } } }
/*------------------------------------------------------------------*\ |* PUBLIC METHODS \*------------------------------------------------------------------*/ public void StartTraining(Entity built, Entity builder) { if (builder.Actions.isBUilding) { return; } var constructionTime = builder.Meta.constructionTime; FunctionDelay.Create(() => CreateCharacter(built, builder), constructionTime); builder.Actions.isBUilding = true; var go = builder.extensions.Find("ProgressBar"); go.gameObject.SetActive(true); var bar = go.GetComponentInChildren <HealthBar>(); bar.InitHealth(100); bar.SetValue(0); bar.FillUpDelay(constructionTime); FunctionDelay.Create(() => { go.gameObject.SetActive(false); }, constructionTime); }
private void CreateBuilding() { var tr = current.transform; var path = $"Prefabs/Entities/Structures/{current.Meta.Class}"; var go = Resources.Load(path) as GameObject; var instance = Instantiate(go, tr.position, tr.rotation); var playerType = current.Owner.playerType; instance.GetComponent <OwnerComponent>().playerType = playerType; instance.transform.parent = InitializationGameObject; var entity = instance.GetComponent <Entity>(); FXFactory.Instance.CreatePuffLarge(Helpers.SetY(tr.position, .8f), 3.5f); FunctionDelay.Create(() => { currentBuilder.ClearTarget(); currentBuilder.SetTarget(entity); entity.State.SetState(entity.State.states[typeof(ConstructionState)]); PlayerController.Instance.PayPrice(entity); }, .1f); ClearCurrent(); }
public void SetDamagesAnimation() { Animator.SetBool(Damages, true); FunctionDelay.Create(DamagesCallback, .1f); }
/*------------------------------------------------------------------*\ |* HOOKS \*------------------------------------------------------------------*/ private void Start() { entity = GetComponent <Entity>(); FunctionDelay.Create(() => townCenter = FindTC(), .5f); }
public void GoBackToWork() { FunctionDelay.Create(() => entity.SetTarget(collectible), .1f); }
public void SetAttackAnimation() { Animator.SetBool(Attack, true); FunctionDelay.Create(AttackCallback, .75f); }
private void ClickTimer() { canInteract = false; FunctionDelay.Create(() => canInteract = true, .5f); }