Exemplo n.º 1
0
    // 发射导弹
    private void Fire()
    {
        // // 播放射击动画
        // m_Animator.SetTrigger("Shoot");

        // 播放射击音效
        AudioSource.PlayClipAtPoint(ShootEffect, ShootingPoint.position);

        // 创建导弹
        Missile instance = Instantiate(MissilePrefab, ShootingPoint.position, Quaternion.identity) as Missile;

        // 如果角色跟导弹的朝向不一致,就翻转导弹
        if (m_PlayerCtrl.FacingRight ^ instance.FacingRight)
        {
            instance.Flip();
        }
    }
Exemplo n.º 2
0
    // 发射导弹
    private void Fire()
    {
        AudioSource.PlayClipAtPoint(ShootEffect, ShootingPoint.position);

        if (ShootingPoint != null)
        {
            Missile instance = Instantiate(MissilePrefab, ShootingPoint.position, Quaternion.identity);
            if (m_PlayerCtrl.FacingRight ^ instance.FacingRight)
            {
                instance.Flip();
            }
        }
        else
        {
            Debug.LogError("请设置射击点");
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    public void Update() { 
        //Loads player UI at beginning of game
        if(!uiSet && GameInit.arena != null) {
            uiSet = true;
            GameInit.arena.setUI(playerNum);
            elementL.sprite = Resources.Load("UI Art Assets/mana/" + elements [0].getName() + "_element", typeof(Sprite)) as Sprite;
            elementR.sprite = Resources.Load("UI Art Assets/mana/" + elements [1].getName() + "_element", typeof(Sprite)) as Sprite;
            Debug.Log("color: "+color.ToString());
			playerPic.sprite = Resources.Load("UI Art Assets/mana/"+color.ToString()+"_figure", typeof(Sprite)) as Sprite;
			if(!isDead)
				anim.runtimeAnimatorController = Resources.Load("Animation Controllers/"+color.ToString()+" Player", typeof(RuntimeAnimatorController)) as RuntimeAnimatorController;
        }
        
        if (!isDead) {
			timeAlive++;
            //turns off animator bools so cast animations do not repeat forever. 
            if(anim.GetCurrentAnimationClipState(0)!= null) {
                if(anim.GetCurrentAnimationClipState(0)[0].clip.name.EndsWith("Cast Slash"))
                    anim.SetBool("Slash", false);
                if (anim.GetCurrentAnimationClipState(0)[0].clip.name.EndsWith("Cast Missile 1"))
                    anim.SetBool("Missile", false);
                if (anim.GetCurrentAnimationClipState(0)[0].clip.name.EndsWith("Cast Wall"))
                    anim.SetBool("Wall", false);
            }
            if(chargeLeft>0)
				chargeLeft--;
			else if(chargeLeft<=0 && charging){
				charging=false;
				chargeLeft=0;
				anim.SetBool("isCharging",false);
			}
            
			float lt = XCI.GetAxis(XboxAxis.LeftTrigger, controllerNum); //true if left trigger is pushed, else false
			float rt = XCI.GetAxis(XboxAxis.RightTrigger, controllerNum); //true if right trigger is pushed, else false
			regenMana();
			if (mana > 100)
				mana = 100;
			if(stunT>0){stunT--;}			
			else{
                if(anim.GetBool("isHit"))
                    anim.SetBool("isHit", false);
                if(anim.GetBool("isBlockAndHit"))
					anim.SetBool("isBlockAndHit", false);
                    
//                if(!casting)
	            //Debug.Log (lt+" || "+rt);
	            //Code for casting Slash
				if (XCI.GetButtonDown(XboxButton.X, controllerNum)) {
	//                elementLoaded.SetActive(false);
	                if (((rt>.5 && lt>.5) || !(rt > .5 || lt > .5)) && casting) {
	                    //Actually, punch, but for now, nothing
	                    //Debug.Log ("I'm here");
	                } 
	                else if(!(rt>.5 || lt>.5) && !casting){
						Punch punch = spells[3].GetComponent("Punch") as Punch;
						if(punch.cd==0){
							punch.start();
							currentSpell=punch;
						}
						else
							playSound("OutOfMana2");
	                }
	                else if(!casting){
	                    bool justMade = false;
	                    if (spells [0] == null) {
	                        slashMaker();
	                        //Slash s=spells[0].GetComponent("Slash") as Slash;
	                        justMade = true;
	                        //s.prepSlash(this,spells[0]);
	                    }
	                    //			Debug.Log(spells[0].transform.position+" HI");
	                    Slash slash = spells [0].GetComponent("Slash") as Slash;
	                    if (lt > .5)
	                        slash.infuse(elements [0]);
	                    else if (rt > .5)
	                        slash.infuse(elements [1]);	
	                    Debug.Log("Slash's Element is " + slash.getElement().getName());
	                    if (mana < slash.getMana()) {
							Debug.Log("no slash mana");
	                        playNoMana();
	                        slash.kill();
	                    }
	                    else {
							slash.sound.Play();
							reduceMana(slash);
	                        currentSpell=slash;
	                        casting = true;
	                        if (slash.casting) {
	                            return;
	                        }
	                        anim.SetFloat("Speed",0);
							slash.charge(); 
					
	                        if (slash.facingRight && !facingRight)
	                            slash.Flip();
	                        else if (!slash.facingRight && facingRight)
	                            slash.Flip();
	                    }
	                }
	            }
				//Code for casting Missile
				else if (XCI.GetButtonDown(XboxButton.B, controllerNum)) {
	                //Debug.Log("FIRE DA MISSILES");
					if ((rt>.5 && lt>.5) || !(rt > .5 || lt > .5) || casting) {
	                    //Actually, dodgeroll, but for now, nothing
	                    //Debug.Log ("I'm here");
	                } 
	                else {
	                    bool justMade = false;
	                    if (spells [1] == null) {
	                        missileMaker();
	                        //Slash s=spells[0].GetComponent("Slash") as Slash;
	                        //justMade = true;
	                        //s.prepSlash(this,spells[0]);
	                    }
	                    //			Debug.Log(spells[0].transform.position+" HI");
	                    Missile missile = Instantiate(spells [1].GetComponent("Missile")) as Missile;
	                    if (lt > .5)
	                        missile.infuse(elements [0]);
	                    else if (rt > .5)
	                        missile.infuse(elements [1]);
	                    Debug.Log("Missile's Element is " + missile.getElement().getName());
	                    if (mana < missile.getMana()){
							Debug.Log("no missile mana");
	                        playNoMana();
	                        missile.kill();
	                    }
	                    else {
							missile.sound.Play();
	                        reduceMana(missile);
	                        currentSpell=missile;
	                        casting = true;
	                        if (missile.casting) {
	                            return;
	                        }
							anim.SetFloat("Speed",0);
							missile.charge();
	
	                        if (missile.facingRight && !facingRight)
	                            missile.Flip();
	                        else if (!missile.facingRight && facingRight)
	                            missile.Flip();
	                    }
	                }
	            } 
	            //code for wall
				else if (XCI.GetButtonDown(XboxButton.Y, controllerNum)) {
					if(!(rt > .5 || lt > .5)){
						setBlock(true);
						anim.SetFloat("Speed", 0f);
						anim.SetBool("isBlocking",true); //?
					}
					else if ((rt>.5 && lt>.5) || casting) {
						//Actually, block, but for now, nothing
						//Debug.Log ("I'm here");
					} 
					else {
						bool justMade = false;
						if (spells [2] == null) {
							wallMaker();
							//Slash s=spells[0].GetComponent("Slash") as Slash;
							//justMade = true;
							//s.prepSlash(this,spells[0]);
						}
						//			Debug.Log(spells[0].transform.position+" HI");
						Wall wall = Instantiate(spells [2].GetComponent("Wall")) as Wall;
						if (lt > .5)
							wall.infuse(elements [0]);
						else if (rt > .5)
							wall.infuse(elements [1]);
						Debug.Log("Missile's Element is " + wall.getElement().getName());
						if (mana < wall.getMana()){
							Debug.Log("no wall mana");
							playNoMana();
							wall.kill();
						}
						else {
							wall.sound.Play();
							reduceMana(wall);
							currentSpell=wall;
							casting = true;
							if (wall.casting) {
								return;
							}
							anim.SetFloat("Speed",0);
							wall.charge();
							
							/*if (wall.facingRight && !facingRight)
								wall.Flip();
							else if (!wall.facingRight && facingRight)
								wall.Flip();*/
						}
					}
				}
				else if(XCI.GetButtonUp(XboxButton.Y, controllerNum) && block){
					block=false;
					anim.SetBool("isBlocking",false);
				}
				else {
				            if (!(rt > .5 && lt > .5) && !casting && !charging) {
														
				                if (lt > .5) {
                                    aura.gameObject.SetActive(true);
                                    aura.color = elements[0].getColor();
                                }
                                else if (rt > .5) {
				                    aura.gameObject.SetActive(true);
                                    aura.color = elements[1].getColor();
                                }
				                else
                                    aura.gameObject.SetActive(false);
				            } else
                                aura.gameObject.SetActive(false);
				}
			}
		}
        //update health and mana bars
		healthBarTrans.sizeDelta = new Vector2(hp * healthSize, healthBarTrans.sizeDelta.y);
		manaBarTrans.sizeDelta = new Vector2(mana * manaSize, manaBarTrans.sizeDelta.y);
    }