Ejemplo n.º 1
0
    protected override void Ability(
        Vector2 position, Vector2 facingDir,
        Animator animator = null, Rigidbody2D rigidbody = null
        )
    {
        Debug.Log(facingDir);
        float facingRotation = Mathf.Atan2(facingDir.y, facingDir.x) * Mathf.Rad2Deg;

        Debug.Log(facingRotation);
        float startRotation = facingRotation + spread / 2f;
        float angleIncrease = spread / ((float)count - 1f);

        for (int i = 0; i < count; i++)
        {
            float      tempRot         = startRotation - angleIncrease * i;
            GameObject projectileClone = Instantiate(
                projectile, position, Quaternion.Euler(0f, 0f, tempRot)
                );
            GenericProjectile temp = projectileClone.GetComponent <GenericProjectile>();

            if (temp)
            {
                temp.Setup(new Vector2(
                               Mathf.Cos(tempRot * Mathf.Deg2Rad), Mathf.Sin(tempRot * Mathf.Deg2Rad))
                           );
            }
        }
    }
Ejemplo n.º 2
0
    public override async void AttackFunction(Effectable singleTarget,
                                              Vector2 SingleTargetPosition)
    {
        int   counter     = NumOfProjectiles;
        float timeCounter = 0;

        if (AsyncAttackInProgress == false)
        {
            AsyncAttackInProgress = true;
            while (counter >= 0)
            {
                if (timeCounter <= 0)
                {
                    GenericProjectile proj = projectilePool.GetInactive();
                    var transform          = proj.transform;
                    transform.position    = ProjectileExitPoints[0].transform.position;
                    transform.rotation    = ProjectileExitPoints[0].transform.rotation;
                    proj.TargetPosition   = ProjectileFinalPoints[0].transform.position;   //can also be projectile final point position
                    proj.EffectableTarget = singleTarget ?? null;

                    proj.Activate();
                    timeCounter = timebetweenProjectiles;
                    counter    -= 1;
                }
                timeCounter -= StaticObjects.DeltaGameTime;
                await Task.Yield();
            }

            AsyncAttackInProgress = false;
        }
    }
Ejemplo n.º 3
0
    void FireProjectile()
    {
        GenericProjectile projFired = Instantiate(projectile.gameObject, firingPoint.position, firingPoint.rotation).GetComponent <GenericProjectile> ();

        projFired.Fire();
        projFired.FireSound.Play();
        onGunFiredEvent(projFired.FireForce);
    }
Ejemplo n.º 4
0
    protected override void Update()
    {
        if (!isPaused)
        {
            Move(Time.unscaledDeltaTime);
            chargeClock += Time.deltaTime;

            if (action && power && !isActive)
            {
                isActive         = true;
                timeStopClock    = 0f;
                charges         -= chargesUsed;
                shouldThrowKnife = true;

                if (timeStopAction != null)
                {
                    timeStopAction.Invoke(true);
                }

                if (charges <= 0)
                {
                    power = false;
                }

                if (UpdateCharges != null)
                {
                    UpdateCharges(charges);
                }
            }
        }

        if (isActive)
        {
            timeStopClock += Time.unscaledDeltaTime;

            if (shouldThrowKnife && timeStopTime >= knifeThrowTime)
            {
                GenericProjectile knifeThrownReference = GameObject.Instantiate(knifePrefab, knifeOrigin.position, Quaternion.identity).GetComponent <GenericProjectile>();
                knifeThrownReference.InitialImpulse(transform.right);
                shouldThrowKnife = false;
                if (!isPlayer1)
                {
                    knifeThrownReference.transform.localScale = new Vector3(-knifeThrownReference.transform.localScale.x, knifeThrownReference.transform.localScale.y, knifeThrownReference.transform.localScale.z);
                }
            }

            if (timeStopClock >= timeStopTime)
            {
                power    = (charges >= chargesUsed && action);
                isActive = false;
                if (timeStopAction != null)
                {
                    timeStopAction.Invoke(false);
                }
            }
        }
    }
Ejemplo n.º 5
0
    void SpawnAsteroid()
    {
        Transform  randomSpawnArea = asteroidSpawnAreas.RandomObject();
        GameObject asteroidSpawn   = asteroidsToSpawn.RandomObject().gameObject;

        GenericProjectile spawnedAsteroid = Instantiate(asteroidSpawn, randomSpawnArea.position, randomSpawnArea.rotation).GetComponent <GenericProjectile> ();

        spawnedAsteroid.Fire();
    }
Ejemplo n.º 6
0
    public override void Ability(Vector2 playerPos, Vector2 playerFacingDirection, Rigidbody2D playerRigidBody = null)
    {
        float      facingRotation = Mathf.Atan2(playerFacingDirection.y, playerFacingDirection.x) * Mathf.Rad2Deg;
        GameObject newProjectile  = Instantiate(projectile, playerPos, Quaternion.Euler(0f, facingRotation, 0f));

        GenericProjectile temp = projectile.GetComponent <GenericProjectile>();

        if (temp)
        {
            temp.Setup(playerFacingDirection);
        }
    }
Ejemplo n.º 7
0
 public PoolObjectQueue <GenericProjectile> GetOrCreateGenericProjectileQueue(GenericProjectile prefab)
 {
     if (GenericProjectilesObjectPoolQueue.ContainsKey(prefab.name))
     {
         return(GenericProjectilesObjectPoolQueue[prefab.name]);
     }
     else
     {
         CreateNewObjectQueue <GenericProjectile>(GenericProjectilesObjectPoolQueue, prefab);
         return(GenericProjectilesObjectPoolQueue[prefab.name]);
     }
 }
Ejemplo n.º 8
0
 public override async void AttackFunction(Effectable singleTarget, Vector2 SingleTargetPosition)
 {
     if (AsyncAttackInProgress == false)
     {
         AsyncAttackInProgress = true;
         GenericProjectile proj = projectilePool.Get();
         var transform          = proj.transform;
         transform.rotation    = ProjectileExitPoints[0].transform.rotation;
         transform.position    = ProjectileExitPoints[0].transform.position;
         proj.TargetPosition   = ProjectileFinalPoints[0].transform.position; // can also be projectile final point position
         proj.EffectableTarget = singleTarget ?? null;
         proj.Activate();
         AsyncAttackInProgress = false;
     }
 }
Ejemplo n.º 9
0
    public override void Ability(Vector2 monsterPosition, Vector2 monsterFacingDirection,
                                 Vector3 mousePosition, Vector3 attackDirection,
                                 Animator monsterAnimator = null, Rigidbody2D monsterRigidBody = null)
    {
        float      projectileRotation = Mathf.Atan2(attackDirection.y, attackDirection.x) * Mathf.Rad2Deg;
        GameObject newProjectile      = Instantiate(thisProjectile, monsterPosition,
                                                    Quaternion.Euler(0f, 0f, projectileRotation));

        GenericProjectile temp = newProjectile.GetComponent <GenericProjectile>();

        if (temp)
        {
            temp.Setup(attackDirection);
        }
    }
Ejemplo n.º 10
0
    // Update is called once per frame
    void Update()
    {
        if (inputManager.IsFire && !OnCooldown)
        {
            FireProjectile();
            StartCoroutine(FireCoolDown(projectile.Cooldown));
        }

        if (timeRemaining > 0 && projectile != defaultProjectile)
        {
            if (Timer())
            {
                projectile = defaultProjectile;
            }
        }
    }
Ejemplo n.º 11
0
    protected override void Ability(
        Vector2 position, Vector2 facingDir,
        Animator animator = null, Rigidbody2D rigidbody = null
        )
    {
        // Debug.Log("HERE");
        float      facingRot       = Mathf.Atan2(facingDir.y, facingDir.x) * Mathf.Rad2Deg;
        GameObject projectileClone = Instantiate(
            projectile, position, Quaternion.Euler(0f, 0f, facingRot)
            );

        GenericProjectile temp = projectileClone.GetComponent <GenericProjectile>();

        if (temp)
        {
            temp.Setup(facingDir);
        }
    }
Ejemplo n.º 12
0
    protected override void Update()
    {
        base.Update();
        if (action && power)
        {
            GenericProjectile missileScriptInstance = GameObject.Instantiate(missilePrefab, projectileOrigin.position, projectileOrigin.rotation).GetComponent <GenericProjectile>();
            missileInstance = missileScriptInstance.gameObject;

            if (!isPlayer1)
            {
                missileInstance.transform.localScale = new Vector3(-missileInstance.transform.localScale.x, missileInstance.transform.localScale.y, missileInstance.transform.localScale.z);
            }

            missileScriptInstance.InitialImpulse(this.transform.right);
            missileScriptInstance.PlatformAction += SpawnExplosion;
            missileScriptInstance.PaletteAction  += SpawnExplosion;
            missileScriptInstance.BallAction     += SpawnExplosion;
            missileScriptInstance.WallAction     += SpawnExplosion;

            canDetonateMissile = false;

            charges -= chargesRequired;
            power    = false;
            if (UpdateCharges != null)
            {
                UpdateCharges(charges);
            }
        }
        else
        {
            if (!action && missileInstance != null)
            {
                canDetonateMissile = true;
            }
        }

        if (action && !power && canDetonateMissile && missileInstance != null)
        {
            SpawnExplosion(missileInstance);
            Destroy(missileInstance);
            canDetonateMissile = false;
        }
    }
Ejemplo n.º 13
0
    public override void Tech(GameObject thisMonster, string otherTag, Vector2 monsterPosition, Vector2 monsterFacingDirection,
                              Vector3 mousePosition, Vector3 attackDirection,
                              Animator monsterAnimator = null, Rigidbody2D monsterRigidBody = null)
    {
        float      projectileRotation = Mathf.Atan2(attackDirection.y, attackDirection.x) * Mathf.Rad2Deg;
        GameObject newProjectile      = Instantiate(thisProjectile, monsterPosition,
                                                    Quaternion.Euler(0f, 0f, projectileRotation));

        GenericProjectile temp = newProjectile.GetComponent <GenericProjectile>();

        newProjectile.GetComponent <TechDamage>().tech        = this;
        newProjectile.GetComponent <TechDamage>().otherTag    = otherTag;
        newProjectile.GetComponent <TechDamage>().thisMonster = thisMonster;

        if (temp)
        {
            temp.Setup(attackDirection);
        }
    }
Ejemplo n.º 14
0
    protected override void Update()
    {
        base.Update();
        if (action && power)
        {
            GenericProjectile smokeBombInstance = GameObject.Instantiate(smokeBombPrefab, projectileOrigin.position, projectileOrigin.rotation).GetComponent <GenericProjectile>();

            smokeBombInstance.InitialImpulse(this.transform.right);
            smokeBombInstance.PlatformAction += SpawnSmokeScreen;
            smokeBombInstance.PaletteAction  += SpawnSmokeScreenPlayer;

            animator.SetTrigger("SHOT");
            charges -= chargesRequired;
            power    = false;
            if (UpdateCharges != null)
            {
                UpdateCharges(charges);
            }
        }
    }
Ejemplo n.º 15
0
    protected override void Update()
    {
        base.Update();
        if (action && power)
        {
            GenericProjectile hadoInstance = GameObject.Instantiate(hadoPrefab, projectileOrigin.position, Quaternion.identity).GetComponent <GenericProjectile>();
            if (!isPlayer1)
            {
                hadoInstance.transform.localScale = new Vector3(-hadoInstance.transform.localScale.x, hadoInstance.transform.localScale.y, hadoInstance.transform.localScale.z);
            }

            hadoInstance.SetImpulse(this.transform.right, hadoSpeedIncrease * charges);
            charges = 0;
            power   = false;
            if (UpdateCharges != null)
            {
                UpdateCharges.Invoke(charges);
            }
        }
    }
Ejemplo n.º 16
0
    public PoolObjectQueue <GenericProjectile> CreatePool(string ParentName)
    {
        GenericProjectile proj = GameObject.Instantiate(ProjectileBase, nowhere, Quaternion.identity);

        proj.BaseProjectileEffect = projectileEffect;
        proj.MovementFunction     = projectileMovement;
        proj.gameObject.SetActive(true);
        proj.OnHitAnimation = OnHitAnimation;
        proj.name           = ParentName + "_" + ProjectileBase.name + "_" + Random.Range(0, 999999);
        GameObject placeholder = GameObject.Instantiate(new GameObject(), Vector3.zero, Quaternion.identity,
                                                        GameObjectPool.Instance.transform);

        placeholder.name = proj.name + "_placeHolder";
        proj.gameObject.SetActive(false);
        PoolObjectQueue <GenericProjectile> pool = new PoolObjectQueue <GenericProjectile>(proj, 10, placeholder);

        //pool.ObjectQueue.Enqueue(proj);
        projectilePool = pool;
        return(pool);
    }
 public override void Ability(Vector2 playerPosition, Vector2 playerFacingPosition, Animator ani = null, Rigidbody2D playerRigidbody = null)
 {
     if (magicCost <= playerMagic.initialValue)
     {
         playerMagic.initialValue -= magicCost;
         playerMagicSignal.Raise();
     }
     else
     {
         return;
     }
     if (thisProjectile)
     {
         float             temp          = Mathf.Atan2(playerFacingPosition.y, playerFacingPosition.x) * Mathf.Rad2Deg;
         GameObject        newGameobject = Instantiate(thisProjectile, playerPosition, Quaternion.Euler(0f, 0f, temp));
         GenericProjectile newProjectile = newGameobject.GetComponent <GenericProjectile>();
         if (newProjectile)
         {
             newProjectile.SetUp(playerFacingPosition);
         }
     }
 }
Ejemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     inputManager      = player.GetComponent <IInput> ();
     defaultProjectile = projectile;
 }