public static Action_Type MapBuildingToAction(Building.Building_Type bt)
    {
        Action_Type at_ = Action_Type.NOTHING;

        switch (bt)
        {
        case Building.Building_Type.Dwelling:
            at_ = Action_Type.Build_Dwelling;
            break;

        case Building.Building_Type.Trading_Post:
            at_ = Action_Type.Build_TP;
            break;

        case Building.Building_Type.Stronghold:
            at_ = Action_Type.Build_Stronghold;
            break;

        case Building.Building_Type.Temple:
            at_ = Action_Type.Build_Temple;
            break;

        case Building.Building_Type.Sanctuary:
            at_ = Action_Type.Build_Sanctuary;
            break;
        }

        return(at_);
    }
 //Point bonus with varying points given.
 public PointBonus(Action_Type at_, int[] pointBonus_)
 {
     PointBonusAr = pointBonus_;
     pointBonus   = 1;
     at           = at_;
     Array        = true;
 }
Beispiel #3
0
        /// <summary>
        /// 新增,刪除,修改 A96 最後交易日
        /// </summary>
        /// <param name="data"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public MSGReturnModel saveA96Trade(A96TradeViewModel data, Action_Type type)
        {
            MSGReturnModel result = new MSGReturnModel();

            result.RETURN_FLAG = false;
            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                var reportDate = TypeTransfer.stringToDateTime(data.Report_Date);
                if (type == Action_Type.Add)
                {
                    db.Bond_Spread_Trade_Info.Add(
                        new Bond_Spread_Trade_Info()
                    {
                        Report_Date     = reportDate,
                        Last_Date       = TypeTransfer.stringToDateTime(data.Last_Date),
                        Create_User     = _UserInfo._user,
                        Create_Date     = _UserInfo._date,
                        Create_Time     = _UserInfo._time,
                        LastUpdate_User = _UserInfo._user,
                        LastUpdate_Date = _UserInfo._date,
                        LastUpdate_Time = _UserInfo._time
                    });
                    result.DESCRIPTION = Message_Type.save_Success.GetDescription();
                }
                else if (type == Action_Type.Dele)
                {
                    db.Bond_Spread_Trade_Info.Remove(db.Bond_Spread_Trade_Info.First(x => x.Report_Date == reportDate));
                    result.DESCRIPTION = Message_Type.delete_Success.GetDescription();
                }
                else if (type == Action_Type.Edit)
                {
                    var _trade = db.Bond_Spread_Trade_Info.FirstOrDefault(x => x.Report_Date == reportDate);
                    if (_trade != null)
                    {
                        _trade.Last_Date       = TypeTransfer.stringToDateTime(data.Last_Date);
                        _trade.LastUpdate_User = _UserInfo._user;
                        _trade.LastUpdate_Date = _UserInfo._date;
                        _trade.LastUpdate_Time = _UserInfo._time;
                    }
                    result.DESCRIPTION = Message_Type.save_Success.GetDescription();
                }
                try
                {
                    db.SaveChanges();
                    result.RETURN_FLAG = true;
                }
                catch (Exception ex) {
                    result.DESCRIPTION = ex.exceptionMessage();
                }
            }

            return(result);
        }
Beispiel #4
0
 public static Action_Type verify_action(Action_Type allowed, Action_Type attempted)
 {
     if ((allowed & attempted) != 0)
     {
         return(attempted);
     }
     else
     {
         attempted &= 0x0;
     }
     return(attempted);
 }
Beispiel #5
0
        /// <summary>
        /// save A95_1 (產業別對應Ticker補登檔)
        /// </summary>
        /// <param name="data"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public MSGReturnModel saveA95_1(A95_1ViewModel data, Action_Type type)
        {
            MSGReturnModel result = new MSGReturnModel();

            result.RETURN_FLAG = false;
            var _tableName = Table_Type.A95_1.tableNameGetDescription();

            if (data == null || data.Bond_Number.IsNullOrWhiteSpace())
            {
                result.DESCRIPTION = Message_Type.parameter_Error.GetDescription(_tableName);
                return(result);
            }
            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                if ((type & Action_Type.Edit) == Action_Type.Edit)
                {
                    var _edit = db.Assessment_Sub_Kind_Ticker.FirstOrDefault(x => x.Bond_Number == data.Bond_Number);
                    if (_edit == null)
                    {
                        result.DESCRIPTION = Message_Type.already_Change.GetDescription(_tableName);
                        return(result);
                    }
                    _edit.Bloomberg_Ticker = data.Bloomberg_Ticker;
                    _edit.Security_Des     = data.Security_Des;
                    _edit.LastUpdate_User  = _UserInfo._user;
                    _edit.LastUpdate_Date  = _UserInfo._date;
                    _edit.LastUpdate_Time  = _UserInfo._time;
                    result.DESCRIPTION     = Message_Type.update_Success.GetDescription(_tableName);
                }
                else if ((type & Action_Type.Dele) == Action_Type.Dele)
                {
                    var _dele = db.Assessment_Sub_Kind_Ticker.FirstOrDefault(x => x.Bond_Number == data.Bond_Number);
                    if (_dele == null)
                    {
                        result.DESCRIPTION = Message_Type.already_Change.GetDescription(_tableName);
                        return(result);
                    }
                    db.Assessment_Sub_Kind_Ticker.Remove(_dele);
                    result.DESCRIPTION = Message_Type.delete_Success.GetDescription(_tableName);
                }
                try
                {
                    db.SaveChanges();
                    result.RETURN_FLAG = true;
                }
                catch (DbUpdateException ex)
                {
                    result.DESCRIPTION = ex.exceptionMessage();
                }
            }
            return(result);
        }
Beispiel #6
0
        public JsonResult saveA96Trade(A96TradeViewModel data, string action, string reportDate)
        {
            MSGReturnModel result  = new MSGReturnModel();
            Action_Type    _action = EnumUtil.GetValues <Action_Type>()
                                     .FirstOrDefault(x => x.ToString() == action);
            DateTime?dt  = null;
            DateTime _dt = DateTime.MinValue;

            if (DateTime.TryParse(reportDate, out _dt))
            {
                dt = _dt;
            }
            result = A9Repository.saveA96Trade(data, _action);
            if (result.RETURN_FLAG)
            {
                var datas = A9Repository.getA96Trade(dt);
                Cache.Invalidate(CacheList.A96TradeDbfileData); //清除
                Cache.Set(CacheList.A96TradeDbfileData, datas); //把資料存到 Cache
            }
            return(Json(result));
        }
    public static Building.Building_Type MapActionToBuilding(Action_Type at_)
    {
        Building.Building_Type bt = Building.Building_Type.NOTHING;
        switch (at_)
        {
        case Action_Type.Have_Dwelling:
            bt = Building.Building_Type.Dwelling; break;

        case Action_Type.Have_TP:
            bt = Building.Building_Type.Trading_Post; break;

        case Action_Type.Have_Temple:
            bt = Building.Building_Type.Temple; break;

        case Action_Type.Have_Sanctuary:
            bt = Building.Building_Type.Sanctuary; break;

        case Action_Type.Have_Stronghold:
            bt = Building.Building_Type.Stronghold; break;
        }
        return(bt);
    }
 public void SetAction(Action_Type a)
 {
     action = a;
 }
 void Update()
 {
     //avoid capturing key events twice
     if (global_index != last_global_index)
     {
         last_global_index = global_index;
         return;
     }
     if (index == global_index || (index == global_count - 1 && global_index == global_count))
     {
         //Select Tracker
         if (Input.GetKeyDown(KeyCode.Alpha8))
         {
             global_index++;
             if (global_index > global_count)
             {
                 global_index = 0;
             }
             tracker.ApplyTracking = savedApply;
             tracker.ShowDebug     = savedDebug;
         }
     }
     if (index == global_index && tracker != null)
     {
         Action_Type priorState = state;
         //Save to prefab
         if (Input.GetKeyDown(KeyCode.Alpha9))
         {
             sensorPosition = tracker.SensorOffset.localPosition;
             sensorRotation = tracker.SensorOffset.localRotation;
             if (Camera.main != null)
             {
                 fieldOfView = Camera.main.fieldOfView;
             }
         }
         else if (Input.GetKeyDown(KeyCode.Alpha0))
         {
             tracker.SensorOffset.localPosition = sensorPosition;
             tracker.SensorOffset.localRotation = sensorRotation;
             if (Camera.main != null)
             {
                 Camera.main.fieldOfView = fieldOfView;
             }
         }
         else if (Input.GetKeyDown(KeyCode.Minus))
         {
             gain -= 1;
             if (gain <= 0)
             {
                 gain = 1;
             }
         }
         else if (Input.GetKeyDown(KeyCode.Equals))
         {
             gain += 1;
         }
         else if (Input.GetKeyDown(KeyCode.I))
         {
             if (state == Action_Type.FieldOfView)
             {
                 state = Action_Type.None;
             }
             else
             {
                 state = Action_Type.FieldOfView;
             }
         }
         else if (Input.GetKeyDown(KeyCode.O))
         {
             if (state == Action_Type.Rotate)
             {
                 state = Action_Type.None;
             }
             else
             {
                 state = Action_Type.Rotate;
             }
         }
         else if (Input.GetKeyDown(KeyCode.P))
         {
             if (state == Action_Type.XYAxis)
             {
                 state = Action_Type.None;
             }
             else
             {
                 state = Action_Type.XYAxis;
             }
         }
         else if (Input.GetKeyDown(KeyCode.LeftBracket))
         {
             if (state == Action_Type.XZAxis)
             {
                 state = Action_Type.None;
             }
             else
             {
                 state = Action_Type.XZAxis;
             }
         }
         if (priorState == Action_Type.None && (int)state > 0)
         {
             savedApply = tracker.ApplyTracking;
             savedDebug = tracker.ShowDebug;
             if (tracker.TrackerType == VRPNManager.Tracker_Types.vrpn_Tracker_MotionNode)
             {
                 tracker.ApplyTracking = VRPNTracker.Transform_Type.None;
             }
             trackerPosition   = tracker.GetPosition();
             trackerRotation   = tracker.GetRotation();
             tracker.ShowDebug = true;
         }
         else if (state != priorState)
         {
             tracker.ApplyTracking = savedApply;
             tracker.ShowDebug     = savedDebug;
         }
         if (state == Action_Type.FieldOfView)
         {
             float fov = Camera.main.fieldOfView;
             fov += gain * 0.01f * Input.GetAxis("Mouse X");
             if (Camera.main != null)
             {
                 Camera.main.fieldOfView = fov;
                 if (plane != null)
                 {
                     Vector3 pos = plane.localPosition;
                     pos.z = (float)(5.0 * plane.localScale.z / Math.Tan(Math.PI * (double)fov / 360.0f));
                     plane.localPosition = pos;
                 }
             }
         }
         else if (state == Action_Type.Rotate)
         {
             if (tracker.TrackerType == VRPNManager.Tracker_Types.vrpn_Tracker_MotionNode)
             {
                 tracker.SensorOffset.localRotation  = Quaternion.Inverse(trackerRotation) * tracker.GetRotation();
                 tracker.SensorOffset.localRotation *= sensorRotation;
             }
             else
             {
                 Vector3    right          = tracker.SensorOffset.localRotation * Vector3.right;
                 Vector3    up             = tracker.SensorOffset.localRotation * Vector3.up;
                 Quaternion mouseXRotation = Quaternion.AngleAxis(-gain * 0.01f * Input.GetAxis("Mouse X"), up);
                 Quaternion mouseYRotation = Quaternion.AngleAxis(-gain * 0.01f * Input.GetAxis("Mouse Y"), right);
                 tracker.SensorOffset.localRotation *= mouseXRotation * mouseYRotation;
             }
         }
         else if (state == Action_Type.XYAxis)
         {
             if (tracker.TrackerType == VRPNManager.Tracker_Types.vrpn_Tracker_MotionNode)
             {
                 Vector3 pos = tracker.SensorOffset.localPosition;
                 pos.x += gain * 0.01f * Input.GetAxis("Mouse X");
                 pos.y += gain * 0.01f * Input.GetAxis("Mouse Y");
                 tracker.SensorOffset.localPosition = pos;
             }
             else
             {
                 tracker.SensorOffset.localPosition = tracker.GetPosition() - trackerPosition;
             }
         }
         else if (state == Action_Type.XZAxis)
         {
             if (tracker.TrackerType == VRPNManager.Tracker_Types.vrpn_Tracker_MotionNode)
             {
                 Vector3 pos = tracker.SensorOffset.localPosition;
                 pos.x += gain * 0.01f * Input.GetAxis("Mouse X");
                 pos.z += gain * 0.01f * Input.GetAxis("Mouse Y");
                 tracker.SensorOffset.localPosition = pos;
             }
             else
             {
                 tracker.SensorOffset.localPosition = tracker.GetPosition() - trackerPosition;
             }
         }
     }
 }
    void Update () {
    	//avoid capturing key events twice
    	if (global_index != last_global_index)
    	{
    		last_global_index = global_index;
    		return;
    	}
    	if (index == global_index || (index == global_count-1 && global_index == global_count))
    	{
    		//Select Tracker
    		if (Input.GetKeyDown(KeyCode.Alpha8))
    		{
    			global_index++;
    			if (global_index > global_count)
    				global_index = 0;
    			tracker.ApplyTracking = savedApply;
    			tracker.ShowDebug = savedDebug;
    		}
    	}
 	   	if (index == global_index && tracker != null)
    	{
    		Action_Type priorState = state;
    		//Save to prefab
    		if (Input.GetKeyDown(KeyCode.Alpha9))
    		{
    			sensorPosition = tracker.SensorOffset.localPosition;
    			sensorRotation = tracker.SensorOffset.localRotation;
    			if (Camera.main != null)
    				fieldOfView = Camera.main.fieldOfView;
    		}
    		else if (Input.GetKeyDown(KeyCode.Alpha0))
    		{
    			tracker.SensorOffset.localPosition = sensorPosition;
    			tracker.SensorOffset.localRotation = sensorRotation;
    			if (Camera.main != null)
    				Camera.main.fieldOfView = fieldOfView;
    		}
    		else if (Input.GetKeyDown(KeyCode.Minus))
    		{
    			gain -= 1;
    			if (gain <= 0)
    				gain = 1;
    		}
    		else if (Input.GetKeyDown(KeyCode.Equals))
    		{
    			gain += 1;
    		}
    		else if (Input.GetKeyDown(KeyCode.I))
    		{
    			if (state == Action_Type.FieldOfView)
    				state = Action_Type.None;
    			else
    				state = Action_Type.FieldOfView;
    		}
    		else if (Input.GetKeyDown(KeyCode.O))
    		{
    			if (state == Action_Type.Rotate)
    				state = Action_Type.None;
    			else
    				state = Action_Type.Rotate;
    		}
    		else if (Input.GetKeyDown(KeyCode.P))
    		{
    			if (state == Action_Type.XYAxis)
    				state = Action_Type.None;
    			else
    				state = Action_Type.XYAxis;
    		}
			else if (Input.GetKeyDown(KeyCode.LeftBracket))
    		{
    			if (state == Action_Type.XZAxis)
    				state = Action_Type.None;
    			else
    				state = Action_Type.XZAxis;
    		}
    		if (priorState == Action_Type.None && (int)state > 0)
    		{
    			savedApply = tracker.ApplyTracking;
    			savedDebug = tracker.ShowDebug;
    			//if (tracker.TrackerType == VRPNManager.Tracker_Types.vrpn_Tracker_MotionNode)
    			//	tracker.ApplyTracking = VRPNTracker.Transform_Type.None;
    			trackerPosition = tracker.GetPosition();
    			trackerRotation = tracker.GetRotation();
    			tracker.ShowDebug = true;
    		}
    		else if (state != priorState)
    		{
    			tracker.ApplyTracking = savedApply;
    			tracker.ShowDebug = savedDebug;
    		}
    		if (state == Action_Type.FieldOfView)
    		{
   				float fov = Camera.main.fieldOfView;
   				fov += gain*0.01f*Input.GetAxis("Mouse X");
   				if (Camera.main != null)
   					{
   					Camera.main.fieldOfView = fov;
   					if (plane != null)
   						{
   						Vector3 pos = plane.localPosition;
   						pos.z = (float)(5.0*plane.localScale.z/Math.Tan(Math.PI*(double)fov/360.0f));
   						plane.localPosition = pos;
   						}
   					}
    		}
    		else if (state == Action_Type.Rotate)
    		{
    			//if (tracker.TrackerType == VRPNManager.Tracker_Types.vrpn_Tracker_MotionNode)
    			//{
    			//	tracker.SensorOffset.localRotation = Quaternion.Inverse(trackerRotation)*tracker.GetRotation();
    			//	tracker.SensorOffset.localRotation *= sensorRotation;
    			//}
    			//else
    			//{
    			//	Vector3 right = tracker.SensorOffset.localRotation * Vector3.right;
    			//	Vector3 up = tracker.SensorOffset.localRotation * Vector3.up;
    			//	Quaternion mouseXRotation = Quaternion.AngleAxis(-gain*0.01f*Input.GetAxis("Mouse X"),up);
    			//	Quaternion mouseYRotation = Quaternion.AngleAxis(-gain*0.01f*Input.GetAxis("Mouse Y"),right);
    			//	tracker.SensorOffset.localRotation *= mouseXRotation * mouseYRotation;
    			//}
    		}
    		else if (state == Action_Type.XYAxis)
    		{
    			//if (tracker.TrackerType == VRPNManager.Tracker_Types.vrpn_Tracker_MotionNode)
    			//{
    			//	Vector3 pos = tracker.SensorOffset.localPosition;
    			//	pos.x += gain*0.01f*Input.GetAxis("Mouse X");
    			//	pos.y += gain*0.01f*Input.GetAxis("Mouse Y");
    			//	tracker.SensorOffset.localPosition = pos;
    			//}
    			//else
    			//	tracker.SensorOffset.localPosition = tracker.GetPosition() - trackerPosition;
    		}
    		else if (state == Action_Type.XZAxis)
    		{
    			//if (tracker.TrackerType == VRPNManager.Tracker_Types.vrpn_Tracker_MotionNode)
    			//{
    			//	Vector3 pos = tracker.SensorOffset.localPosition;
    			//	pos.x += gain*0.01f*Input.GetAxis("Mouse X");
    			//	pos.z += gain*0.01f*Input.GetAxis("Mouse Y");
    			//	tracker.SensorOffset.localPosition = pos;
    			//}
    			//else
    			//	tracker.SensorOffset.localPosition = tracker.GetPosition() - trackerPosition;
    		}
    	}
    }
 /**
  * Returns true if the Action_Type is classified as a reactive action
  */
 public static bool CheckReactive(Action_Type at_)
 {
     return((int)at_ <= 7); //5 and below are all reactive
 }
 public bool Equals(Action_Type at_)
 {
     return((int)at == (int)at_);
 }
 //Default point bonus
 public PointBonus(Action_Type at_, int pointBonus_)
 {
     pointBonus = pointBonus_;
     at         = at_;
     Array      = false;
 }