예제 #1
0
 //鼠标事件判断
 private void MouseEvent(TriggerUnit trigger_unit)
 {
     //是否有目标物体
     if (trigger_unit.TriggerOjb.Length > 0)
     {
         GameObject aimObj = RayCollision();
         if (aimObj)
         {
             for (int i = 0; i < trigger_unit.TriggerOjb.Length; i++)
             {
                 if (trigger_unit.TriggerOjb[i] == aimObj.name)
                 {
                     //触发成功
                     Debug.Log(aimObj.name + ",该物体被触发, Oh Yeah");
                     MotionPara.triggerPlay = false;
                     break;
                 }
             }
         }
     }
     else
     {
         //触发成功
         Debug.Log("触发成功,无目标物体, Oh Yeah");
         MotionPara.triggerPlay = false;
     }
 }
예제 #2
0
    public virtual bool excute(_Shoot3 shoot, int subId, TriggerUnit trigger)
    {
        reload(shoot);


        // リロードの必要ないユニットの場合もあるので、リロード中でも一応通す。

        var statesMain = units.Length > subId ? units[subId].excute(shoot, this, trigger): enWaponState.ready;


        var isExcuting = ((int)statesMain & (int)enWaponState.excuting) != 0;

        return(isExcuting);
    }
예제 #3
0
    // 実行 --------------------------------------------------------

    public virtual bool excute(_Shoot3 shoot, TriggerUnit mainTrigger, TriggerUnit subTrigger)
    {
        reload(shoot);


        // リロードの必要ないユニットの場合もあるので、リロード中でも一応通す。

        var statesMain = units.Length > 0 ? units[0].excute(shoot, this, mainTrigger): enWaponState.ready;

        var statesSub = units.Length > 1 ? units[1].excute(shoot, this, subTrigger) : enWaponState.ready;


        var isExcuting = (((int)statesMain | (int)statesSub) & (int)enWaponState.excuting) != 0;

        return(isExcuting);
    }
예제 #4
0
    //需要考虑单独的触发,组合触发,多个触发中的任一触发


    //单个触发控制函数
    private void SingleTrigger(Event current_event, TriggerUnit trigger_unit)
    {
        //鼠标按下或双击
        if (trigger_unit.TriggerType[0] == TriggerType.MouseDown || trigger_unit.TriggerType[0] == TriggerType.MouseDown2)
        {
            if (current_event.type == EventType.MouseDown)
            {
                //鼠标单击事件
                if (current_event.clickCount == 1 && trigger_unit.TriggerType[0] == TriggerType.MouseDown)
                {
                    //判断按键是否符合
                    if (current_event.button.ToString() == trigger_unit.TriggerKey[0])
                    {
                        MouseEvent(trigger_unit);
                    }
                }
                //鼠标双击事件
                else if (current_event.clickCount == 2 && trigger_unit.TriggerType[0] == TriggerType.MouseDown2)
                {
                    //判断按键是否符合
                    if (current_event.button.ToString() == trigger_unit.TriggerKey[0])
                    {
                        MouseEvent(trigger_unit);
                    }
                }
            }
        }
        //鼠标抬起
        else if (trigger_unit.TriggerType[0] == TriggerType.MouseUp)
        {
            if (current_event.type == EventType.MouseUp)
            {
                //鼠标单击事件
                if (current_event.clickCount == 1)
                {
                    //判断按键是否符合
                    if (current_event.button.ToString() == trigger_unit.TriggerKey[0])
                    {
                        MouseEvent(trigger_unit);
                    }
                }
            }
        }
        //鼠标拖拽
        else if (trigger_unit.TriggerType[0] == TriggerType.MouseDrag)
        {
            //鼠标拖拽事件
            if (current_event.type == EventType.MouseDrag)
            {
                //判断按键是否符合
                if (current_event.button.ToString() == trigger_unit.TriggerKey[0])
                {
                    MouseEvent(trigger_unit);
                }
            }
        }
        //鼠标滚轮滚动
        else if (trigger_unit.TriggerType[0] == TriggerType.ScrollWheel)
        {
            //鼠标滚轮事件
            if (current_event.type == EventType.ScrollWheel)
            {
                MouseEvent(trigger_unit);
            }
        }
        //键盘按键按下
        else if (trigger_unit.TriggerType[0] == TriggerType.KeyDown)
        {
            if (current_event.type == EventType.KeyDown)
            {
                //Debug.Log(current_event.keyCode.ToString());
                //判断按键是否符合
                //TODO:按键需要做一个映射
                if (current_event.keyCode.ToString().ToLower() == trigger_unit.TriggerKey[0])
                {
                    KeyboardEvent(trigger_unit);
                }
            }
        }
        //键盘按键抬起
        else if (trigger_unit.TriggerType[0] == TriggerType.KeyUp)
        {
            if (current_event.type == EventType.KeyUp)
            {
                //Debug.Log(current_event.keyCode.ToString());
                //判断按键是否符合
                //TODO:按键需要做一个映射
                if (current_event.keyCode.ToString().ToLower() == trigger_unit.TriggerKey[0])
                {
                    KeyboardEvent(trigger_unit);
                }
            }
        }
    }
예제 #5
0
 //键盘事件判断
 private void KeyboardEvent(TriggerUnit trigger_unit)
 {
     //触发成功
     MotionPara.triggerPlay = false;
 }
예제 #6
0
 //ATENTION
 //多个触发,暂时只支持两个触发,且只能是鼠标和鼠标,键盘和键盘
 private void SeveralTriggers(Event current_event, TriggerUnit trigger_unit)
 {
     //鼠标触发
     if (trigger_unit.TriggerType[0] == TriggerType.MouseDown || trigger_unit.TriggerType[0] == TriggerType.MouseUp)
     {
         int btn1 = 0;
         try
         {
             btn1 = int.Parse(trigger_unit.TriggerKey[0]);
         }
         catch
         {
             Debug.LogError("Key按键填写的格式错误!");
             return;
         }
         int btn2 = 0;
         try
         {
             btn2 = int.Parse(trigger_unit.TriggerKey[1]);
         }
         catch
         {
             Debug.LogError("Key按键填写的格式错误!");
             return;
         }
         //第二个按键按下
         if (trigger_unit.TriggerType[1] == TriggerType.MouseDown)
         {
             if (Input.GetMouseButton(btn1) && Input.GetMouseButtonDown(btn2))
             {
                 MouseEvent(trigger_unit);
             }
         }
         //第二个按键抬起
         else if (trigger_unit.TriggerType[1] == TriggerType.MouseUp)
         {
             if (Input.GetMouseButton(btn1) && Input.GetMouseButtonUp(btn2))
             {
                 MouseEvent(trigger_unit);
             }
         }
     }
     //键盘触发
     else if (trigger_unit.TriggerType[0] == TriggerType.KeyDown || trigger_unit.TriggerType[0] == TriggerType.KeyUp)
     {
         //第二个按键按下
         if (trigger_unit.TriggerType[1] == TriggerType.KeyDown)
         {
             if (Input.GetKey(trigger_unit.TriggerKey[0].ToLower()) && Input.GetKeyDown(trigger_unit.TriggerKey[1].ToLower()))
             {
                 KeyboardEvent(trigger_unit);
             }
         }
         //第二个按键抬起
         else if (trigger_unit.TriggerType[1] == TriggerType.KeyUp)
         {
             if (Input.GetKey(trigger_unit.TriggerKey[0].ToLower()) && Input.GetKeyUp(trigger_unit.TriggerKey[1].ToLower()))
             {
                 KeyboardEvent(trigger_unit);
             }
         }
     }
 }
예제 #7
0
    //Trigger控制模块
    private IEnumerator TriggerCoroutine(string trigger_str, DataTable trigger_table)
    {
        TriggerManager.triggerUnitList.Clear();
        string[] triggerArray = trigger_str.Split('|');
        for (int i = 0; i < triggerArray.Length; i++) {
            //获取Trigger ID
			string triggerKeyStr = InterData.CmdCheck(triggerArray[i], "TRIGGER");
            if (triggerKeyStr != "") {
                //TRIGGER信息提取
                DataRow triggerRowData = trigger_table.Rows.Find(triggerKeyStr);
                //ID获取TRIGGER行失败
                if (triggerRowData == null)
                {
                    MotionPara.shouldStop = stopInRow;
                    if (MotionPara.isEditor)
                    {
                        Debug.LogError(ErrorLocation.Locate("MAIN", "TRIGGER", MotionPara.mainRowNumber) + ", TRIGGER 没有这个ID!");
                    }
                    yield break;
                }
                //开始提取表格信息
                TriggerUnit tempUnit = new TriggerUnit();
                //ID
                tempUnit.ID = i;
                //触发类型
                string typeStr = ((string)triggerRowData[2].ToString()).ToUpper();
                bool isRight = true;
                tempUnit.TriggerType = InterData.GetTriggerType(typeStr, ref isRight);
                if (!isRight)
                {
                    MotionPara.shouldStop = stopInRow;
                    //编辑器模式下会出现警报信息
                    if (MotionPara.isEditor)
                    {
                        Debug.LogError(ErrorLocation.Locate("TRIGGER", "TYPE", triggerKeyStr));
                        yield break;
                    }
                }
                //触发按键
                string keyStr = ((string)triggerRowData[3].ToString()).ToLower();
                tempUnit.TriggerKey = keyStr.Split('&');
                //触发物体
                string objStr = (string)triggerRowData[4].ToString();
                tempUnit.TriggerOjb = objStr.Split('&');
				//按钮触发类型
				for (int j = 0; j < tempUnit.TriggerType.Length; j++)
				{
					if (j == 0)
						tempUnit.BtnFuncList = new List<string>();
					if (tempUnit.TriggerType[j] == TriggerType.Button)
					{
						try
						{
							tempUnit.BtnFuncList.Add(tempUnit.TriggerKey[j].ToUpper());
						}
						catch 
						{
							Debug.LogError(ErrorLocation.Locate("TRIGGER", "KEY", triggerKeyStr) + ",Key的个数要与触发类型的个数一致!");
							yield break;
						}
					}
				}

				TriggerManager.triggerUnitList.Add(tempUnit);
            }else{
                MotionPara.shouldStop = stopInRow;
                //编辑器模式下会出现警报信息
                if (MotionPara.isEditor)
                {
                    Debug.LogError(ErrorLocation.Locate("MAIN", "TRIGGER", MotionPara.mainRowNumber));
                    yield break;
                }
            }
        }
        st_Trigger.gameObject.SetActive(true);
        MotionPara.triggerPlay = true;
		//如果有GUI按钮的情况
		BtnFunction.AllForbit();
		for (int i = 0; i < TriggerManager.triggerUnitList.Count; i++)
		{
			if (TriggerManager.triggerUnitList[i].BtnFuncList != null) 
			{
				for (int j = 0; j < TriggerManager.triggerUnitList[i].BtnFuncList.Count; j++)
				{
					BtnFunction.SetBtn(TriggerManager.triggerUnitList[i].BtnFuncList[j], true);
				}
			}
		}
        yield return StartCoroutine(TriggerTimer());

        //yield return null;
    }
예제 #8
0
    //需要考虑单独的触发,组合触发,多个触发中的任一触发


	//单个触发控制函数
    private void SingleTrigger(Event current_event, TriggerUnit trigger_unit)
    {
        //鼠标按下或双击
        if (trigger_unit.TriggerType[0] == TriggerType.MouseDown || trigger_unit.TriggerType[0] == TriggerType.MouseDown2) 
        {
            if (current_event.type == EventType.MouseDown) 
            {
                //鼠标单击事件
                if (current_event.clickCount == 1 && trigger_unit.TriggerType[0] == TriggerType.MouseDown)
                {
                    //判断按键是否符合
                    if (current_event.button.ToString() == trigger_unit.TriggerKey[0])
                    {
                        MouseEvent(trigger_unit);
                    }
                }
                //鼠标双击事件
				else if (current_event.clickCount == 2 && trigger_unit.TriggerType[0] == TriggerType.MouseDown2)
				{
					//判断按键是否符合
					if (current_event.button.ToString() == trigger_unit.TriggerKey[0])
					{
						MouseEvent(trigger_unit);
					}
				}
            }
        }
        //鼠标抬起
        else if (trigger_unit.TriggerType[0] == TriggerType.MouseUp)
        {
			if (current_event.type == EventType.MouseUp)
			{
				//鼠标单击事件
				if (current_event.clickCount == 1)
				{
					//判断按键是否符合
					if (current_event.button.ToString() == trigger_unit.TriggerKey[0])
					{
						MouseEvent(trigger_unit);
					}
				}
			}
        }
        //鼠标拖拽
        else if (trigger_unit.TriggerType[0] == TriggerType.MouseDrag)
        {
            //鼠标拖拽事件
            if (current_event.type == EventType.MouseDrag)
            {
				//判断按键是否符合
				if (current_event.button.ToString() == trigger_unit.TriggerKey[0])
				{
					MouseEvent(trigger_unit);
				}
            }
        }
        //鼠标滚轮滚动
        else if (trigger_unit.TriggerType[0] == TriggerType.ScrollWheel)
        {
            //鼠标滚轮事件
            if (current_event.type == EventType.ScrollWheel)
            {
                MouseEvent(trigger_unit);
            }
        }
		//键盘按键按下
		else if (trigger_unit.TriggerType[0] == TriggerType.KeyDown) 
		{
            if (current_event.type == EventType.KeyDown)
            {
				//Debug.Log(current_event.keyCode.ToString());
				//判断按键是否符合
				//TODO:按键需要做一个映射
				if (current_event.keyCode.ToString().ToLower() == trigger_unit.TriggerKey[0])
				{
					KeyboardEvent(trigger_unit);
				}
            }
		}
		//键盘按键抬起
		else if (trigger_unit.TriggerType[0] == TriggerType.KeyUp) 
		{
            if (current_event.type == EventType.KeyUp)
            {
				//Debug.Log(current_event.keyCode.ToString());
				//判断按键是否符合
				//TODO:按键需要做一个映射
				if (current_event.keyCode.ToString().ToLower() == trigger_unit.TriggerKey[0])
				{
					KeyboardEvent(trigger_unit);
				}
            }
		}
    }
예제 #9
0
	//键盘事件判断
	private void KeyboardEvent(TriggerUnit trigger_unit)
	{ 
		//触发成功
        MotionPara.triggerPlay = false;
	}
예제 #10
0
 //鼠标事件判断
 private void MouseEvent(TriggerUnit trigger_unit)
 {
     //是否有目标物体
     if (trigger_unit.TriggerOjb.Length > 0)
     {
         GameObject aimObj = RayCollision();
         if (aimObj)
         {
             for (int i = 0; i < trigger_unit.TriggerOjb.Length; i++)
             {
                 if (trigger_unit.TriggerOjb[i] == aimObj.name)
                 {
                     //触发成功
                     Debug.Log(aimObj.name + ",该物体被触发, Oh Yeah");
                     MotionPara.triggerPlay = false;
                     break;
                 }
             }
         }
     }
     else
     {
         //触发成功
         Debug.Log("触发成功,无目标物体, Oh Yeah");
         MotionPara.triggerPlay = false;
     }
 }
예제 #11
0
	//ATENTION
	//多个触发,暂时只支持两个触发,且只能是鼠标和鼠标,键盘和键盘
	private void SeveralTriggers(Event current_event, TriggerUnit trigger_unit)
	{
		//鼠标触发
		if (trigger_unit.TriggerType[0] == TriggerType.MouseDown || trigger_unit.TriggerType[0] == TriggerType.MouseUp) 
		{
			int btn1 = 0;
			try
			{
				btn1 = int.Parse(trigger_unit.TriggerKey[0]);
			}
			catch 
			{
				Debug.LogError("Key按键填写的格式错误!");
				return;
			}
			int btn2 = 0;
			try
			{
				btn2 = int.Parse(trigger_unit.TriggerKey[1]);
			}
			catch
			{
				Debug.LogError("Key按键填写的格式错误!");
				return;
			}
			//第二个按键按下
			if (trigger_unit.TriggerType[1] == TriggerType.MouseDown) {
				if (Input.GetMouseButton(btn1) && Input.GetMouseButtonDown(btn2))
				{
					MouseEvent(trigger_unit);
				}
			}
			//第二个按键抬起
			else if (trigger_unit.TriggerType[1] == TriggerType.MouseUp)
			{
				if (Input.GetMouseButton(btn1) && Input.GetMouseButtonUp(btn2))
				{
					MouseEvent(trigger_unit);
				}
			}	
		}
		//键盘触发
		else if (trigger_unit.TriggerType[0] == TriggerType.KeyDown || trigger_unit.TriggerType[0] == TriggerType.KeyUp) 
		{
			//第二个按键按下
			if (trigger_unit.TriggerType[1] == TriggerType.KeyDown) {
				if (Input.GetKey(trigger_unit.TriggerKey[0].ToLower()) && Input.GetKeyDown(trigger_unit.TriggerKey[1].ToLower())) {
					KeyboardEvent(trigger_unit);
				}
			}
			//第二个按键抬起
			else if (trigger_unit.TriggerType[1] == TriggerType.KeyUp) 
			{
				if (Input.GetKey(trigger_unit.TriggerKey[0].ToLower()) && Input.GetKeyUp(trigger_unit.TriggerKey[1].ToLower()))
				{
					KeyboardEvent(trigger_unit);
				}
			}
		}
	}