Пример #1
0
    public IEnumerator attack4()
    {
        int numberOfBullets = 7;

        GameObject[] bullets = new GameObject[numberOfBullets];
        //GameObject[] blasts = new GameObject[numberOfBullets];

        RpcSetTrigger("Attack4Trigger");
        for (int i = 0; i < numberOfBullets; i++)
        {
            Vector3 localTransform = bulletSpawn.position;
            //localTransform.z += 1.0f;

            bullets[i] = Instantiate(bullet, localTransform, transform.rotation);
            NetworkServer.Spawn(bullets[i]);
            yield return(new WaitForSeconds(0.2f));
        }

        yield return(new WaitForSeconds(0.5f));

        for (int i = 0; i < numberOfBullets; i++)
        {
            bullets[i].GetComponent <Rigidbody>().velocity = bullets[i].transform.forward * 15;
            Destroy(bullets[i], 6);
        }

        player    = null;
        mageState = MageState.idle;
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        if (blast == null)
        {
            blast = GameObject.Find("Attack1Blast");
        }
        if (blastWave == null)
        {
            blastWave = GameObject.Find("Attack2BlastWave");
        }

        cam        = GameObject.FindGameObjectWithTag("MainCamera");
        earthquake = GetComponent <AudioSource>();

        isEnemySpawning = false;
        teleportIn      = false;
        teleportOut     = false;
        canTakeDamage   = true;
        //hit = false;
        rate = 0;

        //mageLevel = MageLevel.level1;
        mageState    = MageState.idle;
        healthScript = GetComponent <Health>();

        morphLight.GetComponent <Light>().intensity = 0;
        morphLight.SetActive(false);
        //tree.transform.localScale.Set(0.1f, 0.1f, 0.1f);
        tree.SetActive(false);
        flowchart.gameObject.SetActive(false);
        anim = GetComponent <NetworkAnimator>();

        raycastLayer = 1 << LayerMask.NameToLayer("Player");
    }
Пример #3
0
    public IEnumerator death()
    {
        mageState = MageState.doNothing;
        RpcSetTrigger("Death");
        yield return(new WaitForSeconds(5.0f));

        morphLight.transform.position = new Vector3(transform.position.x, transform.position.y + 2, transform.position.z);
        morphLight.SetActive(true);
        isMorphing = true;

        yield return(new WaitForSeconds(5.0f));

        teleportIn = true;

        yield return(new WaitForSeconds(2.0f));

        earthquake.Play();
        ShakeCamera(0.1f, 15.0f);
        tree.transform.position = transform.position;
        tree.SetActive(true);
        isPlayerMorphing = true;

        isMorphing = false;

        yield return(new WaitForSeconds(15.0f));

        isPlayerMorphing = false;
        print("morph close");
        earthquake.Stop();
    }
Пример #4
0
    public void SearchForTarget()
    {
        if (player == null)
        {
            Collider[] hitColliders = Physics.OverlapSphere(transform.position, radius, raycastLayer);

            if (hitColliders.Length > 0)
            {
                int randomInt = Random.Range(0, hitColliders.Length);
                player    = hitColliders[randomInt].gameObject;
                mageState = MageState.attack;
                //print("player found by " + name);
            }

            else
            {
                mageState = MageState.idle;
            }
        }

        if (player != null && player.GetComponent <CharacterController>().enabled == false)
        {
            player    = null;
            mageState = MageState.idle;
            //print("blooped by " + name);
        }

        //yield return new WaitForSeconds(0.2f);
    }
Пример #5
0
    public IEnumerator attack3()
    {
        RpcSetTrigger("Attack3Trigger");

        yield return(new WaitForSeconds(0.5f));

        Transform closestWaypoint = teleportPos[0];

        foreach (Transform waypoint in teleportPos)
        {
            if (Vector3.Distance(transform.position, waypoint.position) < Vector3.Distance(transform.position, closestWaypoint.position))
            {
                closestWaypoint = waypoint;
            }
        }
        enemySpawned = Instantiate(enemyToSpawn, closestWaypoint.position, transform.rotation);
        enemySpawned.transform.localScale              = new Vector3(0, 0, 0);
        enemySpawned.GetComponent <Enemy>().enabled    = false;
        enemySpawned.GetComponent <Enemy>().waypoints  = teleportPos;
        enemySpawned.GetComponent <Enemy>().enemyState = Enemy.EnemyState.follow;
        NetworkServer.Spawn(enemySpawned);
        isEnemySpawning = true;

        player    = null;
        mageState = MageState.idle;
    }
Пример #6
0
    private void Run(float input)
    {
        Vector2 movement  = rigidbody.velocity;
        Vector3 direction = transform.right * input;

        movement.x         = speed * input;
        rigidbody.velocity = movement;


        if (isGrounded)
        {
            state = MageState.Run;
        }
    }
Пример #7
0
    public IEnumerator attack2()
    {
        RpcSetTrigger("Attack2Trigger");

        yield return(new WaitForSeconds(1.3f));

        GameObject blastWaveSpawned = Instantiate(blastWave, bulletSpawn.transform.position, transform.rotation);

        NetworkServer.Spawn(blastWaveSpawned);
        Destroy(blastWaveSpawned, 6.0f);

        player    = null;
        mageState = MageState.idle;
    }
Пример #8
0
    // ///////////////////////////////////////////////////////////////////////////

    private void Update()
    {
        Quaternion Sotation = Quaternion.Euler(0, 0, 90);

        //Debug.Log(Sotation.z);
        CheckGround();

        sprite.flipX = FlipX;
        patern.flipX = FlipX;

        if (FlipX && stuff.transform.rotation.z > -Sotation.z)
        {
            stuff.transform.Rotate(Vector3.forward, 100 * Time.deltaTime * (-10 * (Sotation.z + stuff.transform.rotation.z)));
        }

        if (!FlipX && stuff.transform.rotation.z < Sotation.z)
        {
            stuff.transform.Rotate(Vector3.forward, 100 * Time.deltaTime * (10 * (Sotation.z - stuff.transform.rotation.z)));
        }

        if (isGrounded)
        {
            state = MageState.Idle;
        }
        else
        {
            state = MageState.Jump;
        }

        if (isLocalPlayer)
        {
            if (Input.GetButton("Horizontal") && isGrounded)
            {
                float input = Input.GetAxis("Horizontal");
                Run(input);
                CmdTurn(input);
            }
            if (Input.GetButton("Cast") && Shtimer >= Shdelay)
            {
                CmdCast();
                //Debug.Log("cast");
            }
            if (Input.GetButton("Jump") && isGrounded && timer >= Jdelay && rigidbody.velocity.magnitude <= Mspeed)
            {
                Jump();
            }
        }
        timer += Time.deltaTime;
    }
Пример #9
0
    public IEnumerator attack1()
    {
        RpcSetTrigger("Attack1Trigger");

        yield return(new WaitForSeconds(0.7f));

        bulletSpawn.LookAt(player.transform);
        GameObject blast = Instantiate(bullet, bulletSpawn.transform.position, bulletSpawn.transform.rotation);

        blast.GetComponent <Rigidbody>().velocity = transform.forward * 15;
        NetworkServer.Spawn(blast);
        Destroy(blast, 6.0f);

        player    = null;
        mageState = MageState.idle;
    }
Пример #10
0
    public IEnumerator hit()
    {
        canTakeDamage = false;
        if (healthScript.currentHealth > 1)
        {
            mageState = MageState.doNothing;
            RpcSetTrigger("Hit");
            yield return(new WaitForSeconds(1.0f));

            mageState = MageState.teleport;
        }
        else
        {
            mageState = MageState.dead;
        }
    }
Пример #11
0
    public IEnumerator teleport()
    {
        mageState = MageState.doNothing;

        canTakeDamage = false;

        RpcSetTrigger("Teleport");
        yield return(new WaitForSeconds(1.5f));

        int temp = Random.Range(0, 8);

        while (randPos == temp)
        {
            temp = Random.Range(0, 8);
        }

        randPos = temp;

        // make it vanish
        teleportIn = true;
        var teleportEffectSpawn = (GameObject)Instantiate(teleportEffect, transform.position, transform.rotation);

        yield return(new WaitForSeconds(1.0f));

        Destroy(teleportEffectSpawn);

        transform.position = teleportPos[randPos].position;
        teleportIn         = false;

        // make it appear
        teleportOut = true;
        yield return(new WaitForSeconds(1.0f));

        teleportOut = false;

        canTakeDamage = true;

        // look for a random player after every teleport
        player    = null;
        mageState = MageState.idle;

        yield return(null);
    }
Пример #12
0
        public MageData(string name, string line, Element element, float elementBonus)
        {
            _name         = name;
            _line         = line;
            _element      = element;
            _currentState = MageState.Dropped;
            _buildingId   = null;
            _mageLevel    = 0;

            _skillEffect = ElementController.Instance.GetSkillPowerInitial(element);
            _damageBonus = elementBonus;

            SetValuesForMageLevel();

            //ToDo: Make Element dependent
            _spellSpeed       = 90;
            _idleCurrency     = UpgradeManager.MageIdleGenerationInitial;
            _skillCoolDown    = 10;
            _minSkillCoolDown = 1;
            _skillRange       = 15;
            _prefabId         = 0;
        }
Пример #13
0
 public void SetState(MageState state)
 {
     _currentState = state;
 }
Пример #14
0
 public void CmdEndScene()
 {
     mageState = MageState.doNothing;
     flowchart.gameObject.SetActive(true);
 }
Пример #15
0
    public void Attack()
    {
        switch (mageLevel)
        {
        case MageLevel.level0:
            break;

        case MageLevel.level1:
            attack1Timer += Time.deltaTime;
            if (attack1Timer > nextAttack1Time)
            {
                CmdAttack1();
                attack1Timer = 0;
            }
            break;

        case MageLevel.level2:
            attack2Timer += Time.deltaTime;
            attack1Timer += Time.deltaTime;
            if (attack1Timer > nextAttack1Time)
            {
                if (attack2Timer > nextAttack2Time)
                {
                    // spawn enemy
                    CmdAttack3();
                    attack2Timer = 0;
                    attack1Timer = 0;
                }
                else
                {
                    CmdAttack1();
                    attack1Timer = 0;
                }
            }
            break;

        case MageLevel.level3:
            attack3Timer += Time.deltaTime;
            attack2Timer += Time.deltaTime;
            attack1Timer += Time.deltaTime;
            if (attack1Timer > nextAttack1Time)
            {
                if (attack2Timer > nextAttack2Time)
                {
                    if (attack3Timer > nextAttack3Time)
                    {
                        CmdAttack4();;
                        attack3Timer = 0;
                        attack2Timer = 0;
                        attack1Timer = 0;
                    }
                    else
                    {
                        // spawn enemy
                        CmdAttack3();
                        attack2Timer = 0;
                        attack1Timer = 0;
                    }
                }
                else
                {
                    CmdAttack1();
                    attack1Timer = 0;
                }
            }
            break;

        case MageLevel.level4:
            tempTimeToTeleport += Time.deltaTime;
            if (tempTimeToTeleport >= timeToTeleport)
            {
                mageState = MageState.teleport;
            }

            attack3Timer += Time.deltaTime;
            attack2Timer += Time.deltaTime;
            attack1Timer += Time.deltaTime;
            if (attack1Timer > nextAttack1Time)
            {
                if (attack2Timer > nextAttack2Time)
                {
                    if (attack3Timer > nextAttack3Time)
                    {
                        CmdAttack4();
                        attack3Timer = 0;
                        attack2Timer = 0;
                        attack1Timer = 0;
                    }
                    else
                    {
                        // spawn enemy
                        CmdAttack3();
                        attack2Timer = 0;
                        attack1Timer = 0;
                    }
                }
                else
                {
                    CmdAttack1();
                    attack1Timer = 0;
                }
            }
            break;
        }
    }