Esempio n. 1
0
 // Start is called before the first frame update
 void Start()
 {
     playerAttackHitbox   = GetComponent <PlayerAttackHitbox>();
     attackHash           = GetComponent <AttackHash>();
     currentAttackState   = IsometricCharacterRenderer.States.none;
     animatedAttackState  = IsometricCharacterRenderer.States.none;
     attackCounter        = 0;
     maxAttackState       = 3;
     currentAttackString  = "";
     animatedAttackString = "";
     setupStateHash();
 }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        if (initialInfoCard != null)
        {
            Camera.main.GetComponent <CameraControl>().pauseAndDrawInfoCard(initialInfoCard);
        }

        if (startInCutscene)
        {
            enterCutscene();
        }
        else
        {
            // Loads Prefabs directly from Resources Folder
            phoneBullet        = ((GameObject)Resources.Load("Phone Attacks/Bullet")).transform;
            phoneLazerBeam     = ((GameObject)Resources.Load("Phone Attacks/LazerBeam")).transform;
            phoneStunBullet    = ((GameObject)Resources.Load("Phone Attacks/StunBullet")).transform;
            phoneStunExplosion = ((GameObject)Resources.Load("Phone Attacks/StunExplosion")).transform;
            phoneStunLight     = ((GameObject)Resources.Load("Phone Attacks/StunLight")).transform;

            playerSprite = transform.FindChild("PlayerSprite");
            flashLight   = GetComponent <FlashlightControl>();

            // Player Audio sources - location in array dependent upon order of player components
            // first audio source listed is source[0]
            aSources               = GetComponents <AudioSource>();
            footStepsAudio         = aSources[0];
            swordAudioChannel      = aSources[1];
            takingDamageAudio      = aSources[2];
            itemPickupAudio        = aSources[3];
            noBatteryAudio         = aSources[4];
            batteryChargingAudio   = aSources[5];
            swordAudioChannel.loop = false;
            takingDamageAudio.loop = false;
            itemPickupAudio.loop   = false;


            curDirection   = FacingDirection.Down;
            curAnim        = transform.FindChild("PlayerSprite").GetComponent <tk2dSpriteAnimator>();
            curHealth      = maxHealth;
            curPhoneCharge = maxPhoneCharge;
            curStamina     = 0;

            rightSideHitbox = GameObject.Find("RightSideAttackHitbox").GetComponent <PlayerAttackHitbox>();
            leftSideHitbox  = GameObject.Find("LeftSideAttackHitbox").GetComponent <PlayerAttackHitbox>();
            upHitbox        = GameObject.Find("UpAttackHitbox").GetComponent <PlayerAttackHitbox>();
            downHitbox      = GameObject.Find("DownAttackHitbox").GetComponent <PlayerAttackHitbox>();

            invulnerable = false;
        }
    }
Esempio n. 3
0
    void AttackInput()
    {
        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            isSprinting = true;
        }
        if (Input.GetKeyUp(KeyCode.LeftShift) || (curStamina < 1))
        {
            isSprinting = false;
        }

        /*
         * //TODO remove this
         * if (Input.GetKeyDown(KeyCode.G)) {
         *      knockBack(new Vector3(1, 0, 0));
         *
         * }*/

        // change to enum/switch
        if (Input.GetKeyDown(KeyCode.S))                                // Phone bullet
        {
            if (hasPhoneLazer)
            {
                PhoneAttackAnimation();
                curState           = PlayerState.chargingLazer;
                lazerChargedAtTime = Time.time + lazerBeamChargeTime;
            }
            else if (hasPhoneBullet)
            {
                PhoneAttackAnimation();
                waitForPhoneAnimationAndFire(PhonePower.Bullet);
            }
        }
        else if (Input.GetKeyDown(KeyCode.D) && hasPhoneStun)                   // Phone stun
        {
            waitForPhoneAnimationAndFire(PhonePower.Stun);
        }
        else if (Input.GetKeyDown(KeyCode.A) && hasSword)                               // Sword Attack
        {
            curState             = PlayerState.SwordAttack;
            swordAttackStartTime = Time.time;
            switch (curDirection)
            {
            case FacingDirection.Up:
                currentAttackHitbox = upHitbox;
                curAnim.Play("swordUp");
                break;

            case FacingDirection.Left:
                currentAttackHitbox = leftSideHitbox;
                curAnim.Play("swordLeft");
                break;

            case FacingDirection.Down:
                currentAttackHitbox = downHitbox;
                curAnim.Play("swordDown");
                break;

            case FacingDirection.Right:
                currentAttackHitbox = rightSideHitbox;
                curAnim.Play("swordRight");
                break;
            }
            currentAttackHitbox.attack(swordDamage, swordAttackStartTime);
            //swordAttack(currentAttackHitbox, swordAttackStartTime);
            swordAudioChannel.Play();
            curAnim.Resume();
            StartCoroutine(waitForAnimationtoEnd());
        }
        else if (Input.GetKeyDown(KeyCode.F))                // flashlight
        {
            flashLight.toggleOnOff();
        }
    }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        if (initialInfoCard != null) {
            Camera.main.GetComponent<CameraControl>().pauseAndDrawInfoCard(initialInfoCard);
        }

        if (startInCutscene) {
            enterCutscene();
        } else {

            // Loads Prefabs directly from Resources Folder
            phoneBullet = ((GameObject) Resources.Load("Phone Attacks/Bullet")).transform;
            phoneLazerBeam = ((GameObject) Resources.Load("Phone Attacks/LazerBeam")).transform;
            phoneStunBullet = ((GameObject) Resources.Load("Phone Attacks/StunBullet")).transform;
            phoneStunExplosion = ((GameObject) Resources.Load("Phone Attacks/StunExplosion")).transform;
            phoneStunLight = ((GameObject) Resources.Load("Phone Attacks/StunLight")).transform;

            playerSprite = transform.FindChild("PlayerSprite");
            flashLight = GetComponent<FlashlightControl>();

            // Player Audio sources - location in array dependent upon order of player components
            // first audio source listed is source[0]
            aSources = GetComponents<AudioSource>();
            footStepsAudio = aSources[0];
            swordAudioChannel = aSources[1];
            takingDamageAudio = aSources[2];
            itemPickupAudio = aSources[3];
            noBatteryAudio = aSources[4];
            batteryChargingAudio = aSources[5];
            swordAudioChannel.loop = false;
            takingDamageAudio.loop = false;
            itemPickupAudio.loop = false;

            curDirection = FacingDirection.Down;
            curAnim = transform.FindChild("PlayerSprite").GetComponent<tk2dSpriteAnimator>();
            curHealth = maxHealth;
            curPhoneCharge = maxPhoneCharge;
            curStamina = 0;

            rightSideHitbox = GameObject.Find("RightSideAttackHitbox").GetComponent<PlayerAttackHitbox>();
            leftSideHitbox = GameObject.Find("LeftSideAttackHitbox").GetComponent<PlayerAttackHitbox>();
            upHitbox = GameObject.Find("UpAttackHitbox").GetComponent<PlayerAttackHitbox>();
            downHitbox = GameObject.Find("DownAttackHitbox").GetComponent<PlayerAttackHitbox>();

            invulnerable = false;

        }
    }
Esempio n. 5
0
    void AttackInput()
    {
        if (Input.GetKeyDown(KeyCode.LeftShift)) {
            isSprinting = true;
        }
        if (Input.GetKeyUp(KeyCode.LeftShift) || (curStamina < 1)) {
            isSprinting = false;
        }
        /*
        //TODO remove this
        if (Input.GetKeyDown(KeyCode.G)) {
            knockBack(new Vector3(1, 0, 0));

        }*/

        // change to enum/switch
        if(Input.GetKeyDown(KeyCode.S)){			// Phone bullet
            if (hasPhoneLazer) {
                PhoneAttackAnimation();
                curState = PlayerState.chargingLazer;
                lazerChargedAtTime = Time.time + lazerBeamChargeTime;
            } else if (hasPhoneBullet) {
                PhoneAttackAnimation();
                waitForPhoneAnimationAndFire(PhonePower.Bullet);
            }
        } else if (Input.GetKeyDown(KeyCode.D) && hasPhoneStun) {	// Phone stun
            waitForPhoneAnimationAndFire(PhonePower.Stun);
        } else if(Input.GetKeyDown(KeyCode.A) && hasSword){			// Sword Attack
            curState = PlayerState.SwordAttack;
            swordAttackStartTime = Time.time;
            switch(curDirection)
            {
                case FacingDirection.Up:
                currentAttackHitbox = upHitbox;
                curAnim.Play("swordUp");
                break;
                case FacingDirection.Left:
                currentAttackHitbox = leftSideHitbox;
                curAnim.Play("swordLeft");
                break;
                case FacingDirection.Down:
                currentAttackHitbox = downHitbox;
                curAnim.Play("swordDown");
                break;
                case FacingDirection.Right:
                currentAttackHitbox = rightSideHitbox;
                curAnim.Play("swordRight");
                break;
            }
            currentAttackHitbox.attack(swordDamage, swordAttackStartTime);
            //swordAttack(currentAttackHitbox, swordAttackStartTime);
            swordAudioChannel.Play ();
            curAnim.Resume();
            StartCoroutine(waitForAnimationtoEnd());
        } else if (Input.GetKeyDown(KeyCode.F)) {    // flashlight
            flashLight.toggleOnOff();
        }
    }