Exemple #1
0
    /*------------------------------------------------------------------*\
    |*							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);
    }
Exemple #2
0
        public void Attack()
        {
            Engaging.HardLookAtTarget();
            Entity.Animation.SetAttackAnimation();

            FunctionDelay.Create(AttackCallback, Engaging.AttackDelay);
        }
Exemple #3
0
 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);
 }
Exemple #5
0
        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
                                 );
        }
Exemple #6
0
 public void SetDamagesAnimation()
 {
     Animator.SetBool(DAMAGES, true);
     Entity.Agent.speed        = 0;
     Entity.Agent.acceleration = 1000f;
     FunctionDelay.Create(DamagesCallback, 0.1f);
 }
Exemple #7
0
        public void Attack()
        {
            Entity.Engaging.HardLookAtTarget();
            Entity.Animation.SetAttackAnimation();

            FunctionDelay.Create(AttackCallback, .2f);
            FunctionDelay.Create(() => Entity.Animation.SetIdleAnimation(), .75f);
        }
Exemple #8
0
    /*------------------------------------------------------------------*\
    |*							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);
    }
Exemple #9
0
 public void Update()
 {
     if (!Entity.Engaging.IsTargetAlive() || !Entity.Engaging.IsTargetInRange())
     {
         FunctionDelay.Create(
             () => {
             Entity.ClearTarget();
             Entity.ClearDestination();
         }, .4f
             );
     }
 }
Exemple #10
0
    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
                             );
    }
Exemple #11
0
 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);
 }
Exemple #12
0
    /*------------------------------------------------------------------*\
    |*							IState IMPLEMENTATION
    \*------------------------------------------------------------------*/

    public void Update()
    {
        if (!entity.Interaction.TargetFinished() && entity.Interaction.TargetInRange())
        {
            entity.Interaction.Interact();
        }
        else
        {
            FunctionDelay.Create(
                () => {
                entity.ClearTarget();
                entity.ClearDestination();
            },
                .4f
                );
        }
    }
Exemple #13
0
    private void DisableComponents(bool soft)
    {
        if (State)
        {
            State.Current.OnExit();
        }
        // State = null;
        Selectable = null;
        Awareness  = null;

        if (soft)
        {
            FunctionDelay.Create(DisablePhysics, .5f);
        }
        else
        {
            DisablePhysics();
        }
    }
Exemple #14
0
        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);
                }
            }
        }
Exemple #15
0
        /*------------------------------------------------------------------*\
        |*							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);
        }
Exemple #16
0
        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();
        }
Exemple #17
0
 public void SetDamagesAnimation()
 {
     Animator.SetBool(Damages, true);
     FunctionDelay.Create(DamagesCallback, .1f);
 }
Exemple #18
0
        /*------------------------------------------------------------------*\
        |*							HOOKS
        \*------------------------------------------------------------------*/

        private void Start()
        {
            entity = GetComponent <Entity>();
            FunctionDelay.Create(() => townCenter = FindTC(), .5f);
        }
Exemple #19
0
 public void GoBackToWork()
 {
     FunctionDelay.Create(() => entity.SetTarget(collectible), .1f);
 }
Exemple #20
0
 public void SetAttackAnimation()
 {
     Animator.SetBool(Attack, true);
     FunctionDelay.Create(AttackCallback, .75f);
 }
Exemple #21
0
 private void ClickTimer()
 {
     canInteract = false;
     FunctionDelay.Create(() => canInteract = true, .5f);
 }