Пример #1
0
        public override void BeginToUse(Actor actorUsing, OnUsed <Actor> onUseBegin, OnUsed <Actor> onDynamicItemUsed)
        {
            //Casting projectile here
            this.actorUsing = actorUsing;
            onUseOver       = onDynamicItemUsed;

            attack = actorUsing.currentAttack;
            projectileTypeThrown = actorUsing.currentAttack.projectiles;
            actorHadAuthority    = actorUsing.hasAuthority();
            gameObjectInstanceId = actorUsing.gameObject.GetInstanceID();
            ownerId = actorUsing.ownerId;
            //Debug.LogError("PProjectile to throw type "+projectileTypeThrown.ToString());
            GameObject gToSpawn = Resources.Load(projectileTypeThrown.ToString()) as GameObject;

            if (gToSpawn == null)
            {
                Debug.LogError("gToSpawn is null");
                return;
            }
            liveProjectile = GridManager.InstantiateGameObject(gToSpawn).GetComponent <ProjectileUtil>();
            liveProjectile.transform.position = GridManager.instance.cellToworld(actorUsing.positionToSpawnProjectile);
            initPos  = liveProjectile.transform.position;
            finalPos = actorUsing.actorTransform.position + (liveProjectile.projectileTileTravelDistance * GridManager.instance.GetFacingDirectionOffsetVector3(actorUsing.Facing));
            tileMovementDirection = actorUsing.Facing;
            liveProjectile.Initialise(this);

            //if (projectileTypeThrown==EnumData.Projectiles.FlamePillar)
            //{
            //    liveProjectile.transform.position = actorUsing.actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(actorUsing.Facing);
            //    finalPos = actorUsing.actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(actorUsing.Facing) + (liveProjectile.projectileTileTravelDistance * GridManager.instance.GetFacingDirectionOffsetVector3(actorUsing.Facing));
            //}
        }
Пример #2
0
 public virtual bool Use()
 {
     if (CanUse())
     {
         AmountStack--;
         OnUsed?.Invoke();
         return(true);
     }
     OnFailUsed?.Invoke();
     return(false);
 }
Пример #3
0
 public void OnPointerUp(PointerEventData eventData)
 {
     if (_buidlingInstance.GetComponent <BuildingDragger>().PutDownCube())
     {
         OnUsed?.Invoke();
         Destroy(this.gameObject);
     }
     else
     {
         Destroy(_buidlingInstance);
     }
 }
Пример #4
0
    public void Use()
    {
        if (!CanUse())
        {
            return;
        }

        _cooldown = 1 / _useSpeed;

        if (_hasAmmunition)
        {
            _currentAmmunition -= 1;

            if (_currentAmmunition == 0)
            {
                Reload();
            }
        }

        OnUsed?.Invoke();
    }
    public override void BeginToUse(Actor actorUsing, OnUsed <Actor> onUseBegin, OnUsed <Actor> onDynamicItemUsed)
    {
        //Casting projectile here
        this.actorUsing = actorUsing;
        onUseOver       = onDynamicItemUsed;

        actorFacingWhenFired = actorUsing.Facing;
        gameObjectInstanceId = actorUsing.gameObject.GetInstanceID();
        ownerId = actorUsing.ownerId;

        GameObject gToSpawn = Resources.Load(actorUsing.projectileThrownType.ToString()) as GameObject;

        if (gToSpawn == null)
        {
            Debug.LogError("gToSpawn is null");
            return;
        }
        liveProjectile = GridManager.InstantiateGameObject(gToSpawn).GetComponent <ProjectileUtil>();
        liveProjectile.transform.position = actorUsing.actorTransform.position;
        finalPos = actorUsing.actorTransform.position + (liveProjectile.projectileTileTravelDistance * GridManager.instance.GetFacingDirectionOffsetVector3(actorUsing.Facing));
        liveProjectile.Initialise(this);
    }
Пример #6
0
        public override void BeginToUse(Actor actorUsing, OnUsed <Actor> onUseBegin, OnUsed <Actor> onDynamicItemUsed)
        {
            base.BeginToUse(actorUsing, onUseBegin, onDynamicItemUsed);
            Vector3    direction    = GetVectorAtAngle(angle, fireDirection, -actorUsing.transform.forward).normalized;
            Vector3Int finalCellPos = GridManager.instance.grid.WorldToCell(actorUsing.positionToSpawnProjectile + (liveProjectile.projectileTileTravelDistance * direction));

            if (angle == 0)
            {
                tileMovementDirection = FaceDirection.Right;
            }
            else if (angle == 90)
            {
                tileMovementDirection = FaceDirection.Down;
            }
            else if (angle == 180)
            {
                tileMovementDirection = FaceDirection.Left;
            }
            else if (angle == 270)
            {
                tileMovementDirection = FaceDirection.Up;
            }
            finalPos = GridManager.instance.cellToworld(finalCellPos);
        }
Пример #7
0
 public DirectionBasedProjectileUse(float angle, Vector3 fireDirection, OnUsed <Vector3Int> OnReachedTargetPoint)
 {
     this.fireDirection = fireDirection;
     this.angle         = angle;
     onPointReached     = OnReachedTargetPoint;
 }
Пример #8
0
 public abstract void BeginToUse(Actor actorUsing, OnUsed <Actor> onUseBegin, OnUsed <Actor> onUseOver);
Пример #9
0
        public ValueType Use()
        {
            OnUsed.Invoke(Value);

            return(Value);
        }
Пример #10
0
 protected void TriggerOnUse()
 {
     OnUsed?.Invoke();
 }