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)); //} }
public virtual bool Use() { if (CanUse()) { AmountStack--; OnUsed?.Invoke(); return(true); } OnFailUsed?.Invoke(); return(false); }
public void OnPointerUp(PointerEventData eventData) { if (_buidlingInstance.GetComponent <BuildingDragger>().PutDownCube()) { OnUsed?.Invoke(); Destroy(this.gameObject); } else { Destroy(_buidlingInstance); } }
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); }
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); }
public DirectionBasedProjectileUse(float angle, Vector3 fireDirection, OnUsed <Vector3Int> OnReachedTargetPoint) { this.fireDirection = fireDirection; this.angle = angle; onPointReached = OnReachedTargetPoint; }
public abstract void BeginToUse(Actor actorUsing, OnUsed <Actor> onUseBegin, OnUsed <Actor> onUseOver);
public ValueType Use() { OnUsed.Invoke(Value); return(Value); }
protected void TriggerOnUse() { OnUsed?.Invoke(); }