Beispiel #1
0
 public Activity(string name, ActivityObject obj, ActivityType type)
 {
     Name      = name;
     Object    = obj;
     Type      = type;
     CreatedAt = DateTime.UtcNow;
 }
        public override async Task <BaseObject> Set(ActivityObject item, ActivityStreamFilter filter)
        {
            var box = GetBox(filter);
            var ctx = new ActivityDeliveryContext {
                context = this, box = box, item = item, Filter = filter
            };
            var ret = await OnBeforeDelivery(ctx);

            if (ret == null)
            {
                ret = await box.Write(item);

                if (ret == null)
                {
                    throw new Exception("Box returned null");
                }
                else if (ret is Error err)
                {
                    return(ret);
                }
                else if (ret is ActivityObject activity)
                {
                    ctx.item = activity;
                    ret      = await OnAfterDelivery(ctx);
                }
                else
                {
                    throw new ArgumentException($"Box returned invalid type {ret.type ?? ret.GetType().FullName}");
                }
            }

            return(ret);
        }
Beispiel #3
0
 private async Task UnReact(ActivityObject reaction, ActivityDeliveryContext ctx)
 {
     foreach (var target in (reaction ?? throw new ArgumentNullException(nameof(reaction))).target.items)
     {
         await _redis.Decrement <ReactionsSummaryModel>($"{reaction.type}Count", target.id, null);
     }
 }
Beispiel #4
0
    private Node findClosestActivityObject()
    {
        Node start  = new Node(npcObject.getX(), npcObject.getY(), color.white, house.start);
        Node target = null;

        foreach (ActivityObject ao in AOList)
        {
            Node tempTarget = new Node(ao.getX(), ao.getY(), color.target, house.target);
            if (!ao.getStatus())
            {
                if (target is null)
                {
                    target       = tempTarget;
                    targetObject = ao;
                }
                else
                {
                    if (tempTarget.GetUclidienDistance(start) < target.GetUclidienDistance(start))
                    {
                        target       = tempTarget;
                        targetObject = ao;
                    }
                }
            }
        }
        return(target);
    }
Beispiel #5
0
    private void OnEnable()
    {
        player         = GameObject.FindGameObjectWithTag("Player");
        movementScript = player.GetComponent <PlayerMovement>();
        playerCamera   = GameObject.FindGameObjectWithTag("MainCamera");
        cameraMovement = playerCamera.GetComponent <MouseLook>();

        activityObject = GameObject.FindGameObjectWithTag("ActivityObject");
        playerActivity = activityObject.GetComponent <ActivityObject>();
    }
        public override async Task <BaseObject> Post(string index, ActivityObject item)
        {
            var publisher = item.actor?.items?.FirstOrDefault();
            var filter    = new ActivityStreamFilter(index)
            {
                id = publisher.PublicId
            };

            return(await Set(item, filter));
        }
Beispiel #7
0
 public void ShowPropertyWindow(UIElement element)
 {
     firstBind = 0;
     _activity = element as SMT.Workflow.Platform.Designer.DesignerControl.ActivityControl;
     if (_activity == null)
     {
         return;
     }
     _activity.Title = _activity.Title;
     #region 新建时创建_activityObject
     if (_activityObject == null)
     {
         ActivityObject obj = ActivityObjects.Where(p => p.ActivityId.Equals("State" + _activity.UniqueID)).SingleOrDefault();
         if (obj == null)
         {
             _activityObject            = new ActivityObject();
             _activityObject.ActivityId = "State" + _activity.UniqueID;
             //if(_activity.
             chkGroupAudit.IsChecked = false;
             HideRows();
             if (_activity.Title.IndexOf("会签") < 0)
             {
                 stateList = WfUtils.StateList;
                 if (Utility.CurrentUser != null)
                 {
                     List <StateType> StateList = WfUtils.GetRoleListByCompanyID(WfUtils.StateList, Utility.CurrentUser.OWNERCOMPANYID);
                     cboRoles.ItemsSource = StateList.OrderBy(c => c.StateName);
                     if (StateList.Count > 0)
                     {
                         isInit = true;
                         if ((cboRoles.Items[0] as StateType).StateName == _activity.Title)
                         {
                             cboRoles.SelectedIndex = 0;
                         }
                         if (_activity.Title.IndexOf("新建") > -1)
                         {
                             cboRoles.SelectedIndex = 0;
                         }
                     }
                     cboUserType.ItemsSource   = WfUtils.GetUserTypeList();
                     cboUserType.SelectedIndex = 0;
                 }
             }
         }
         else
         {
             _activityObject = obj;
         }
     }
     #endregion
     isInit = false;
 }
Beispiel #8
0
 private void Awake()
 {
     npcObject       = gameObject.GetComponent <ActivityObject>();
     manager         = GameObject.FindObjectOfType <WorldManager>();
     algo            = new ASTAR();
     currentState    = new State();
     path            = new List <Node>();
     durration_stemp = Time.time;
     self_name       = gameObject.name;
     health          = status.good;
     canvas          = new CanvasActivity(transform.name, 6);
     canvas_object.setViewParameterForCanvas(canvas);
 }
Beispiel #9
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Debug.Log("exit");
            Application.Quit();
        }
        if (unlockUpdate)
        {
            foreach (GameObject go in activ_list)
            {
                ActivityObject ao = go.GetComponent <ActivityObject>();

                if (ao.getNeed() == activities.social)
                {
                    go.gameObject.transform.position = ao.getLocation();
                    //go.gameObject.transform.Translate( ao.getLocation(),Space.World);

                    NPCObject npc_temp = go.GetComponent <NPCObject>();

                    dict[go].material.SetColor("_Color", npc_temp.getStatusColor());
                    if (npc_temp.getCurrentIdleStats() == idle.searching)
                    {
                        ao.invokeStatusMassage("(" + ao.getX() + "," + ao.getY() + ")");
                    }
                    else
                    {
                        ao.invokeStatusMassage(npc_temp.getOccupiedActivity() + "");
                    }
                }
                else
                {
                    if (ao.getStatus())
                    {
                        ao.invokeStatusMassage("Occupied");
                        dict[go].material.SetColor("_Color", Color.red);
                    }
                    else
                    {
                        ao.invokeStatusMassage("avilable");
                        dict[go].material.SetColor("_Color", Color.green);
                    }
                }
            }
            unlockUpdate = false;
        }
    }
Beispiel #10
0
    public List <ActivityObject> getAllAvilableActivities()
    {
        List <ActivityObject> l = new List <ActivityObject>();

        foreach (GameObject go in activ_list)
        {
            ActivityObject ao = go.GetComponent <ActivityObject>();
            //Debug.Log("object need " + ao.getNeed()+ " vs " + activity);
            if (!ao.getStatus())
            {
                l.Add(ao);
            }
        }

        //Debug.Log(l.Count);
        return(l);
    }
Beispiel #11
0
    public List <ActivityObject> getRelevantActivities(activities activity)
    {
        List <ActivityObject> l = new List <ActivityObject>();

        foreach (GameObject go in activ_list)
        {
            ActivityObject ao = go.GetComponent <ActivityObject>();
            //Debug.Log("object need " + ao.getNeed()+ " vs " + activity);
            if (ao.getNeed() == activity)
            {
                //Debug.Log("match found");
                l.Add(ao);
            }
        }

        //Debug.Log(l.Count);
        return(l);
    }
Beispiel #12
0
        /// <summary>
        /// 更新活动的集合(如果活动不存在,就加入到集合里)
        /// </summary>
        /// <param name="activity">活动</param>
        /// <returns></returns>
        public void UpdateActivityObject(ActivityObject activity)
        {
            var e = from a in ActivityObjects
                    where a.ActivityId == activity.ActivityId
                    select a;
            var ent = e.FirstOrDefault();

            if (ent != null)
            {
                //先删除后增加,保证数据是最新的
                ActivityObjects.Remove(ent);
                ActivityObjects.Add(ent);
            }
            else
            {
                ActivityObjects.Add(activity);
            }
        }
Beispiel #13
0
    private void initTheActivities()
    {
        activ_list = new ArrayList();

        int i, j;

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("fun"))
        {
            Debug.Log("fun");
            ActivityObject ob = go.GetComponent <ActivityObject>();
            ob.setNeed(activities.fun);
            i = Random.Range(2, layout.getSize() - 2);
            j = Random.Range(2, layout.getSize() - 2);
            while (physicalMap.getpathMapValue(i, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j - 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j - 1) is house.wall)
            {
                i = Random.Range(2, layout.getSize() - 2);
                j = Random.Range(2, layout.getSize() - 2);
            }
            worldMap[i, j] = house.unavailable_floor;
            ob.setMapLocation(i, j, size);

            ob.setUpdateable();

            go.gameObject.transform.position = ob.getLocation();
            dict.Add(go, go.GetComponentInChildren <Renderer>());
            activ_list.Add(go);
        }
        //set the entrences objects



        foreach (GameObject go in GameObject.FindGameObjectsWithTag("bladder"))
        {
            Debug.Log("bladder");
            ActivityObject ob = go.GetComponent <ActivityObject>();
            ob.setNeed(activities.bladder);
            i = Random.Range(2, layout.getSize() - 2);
            j = Random.Range(2, layout.getSize() - 2);
            while (physicalMap.getpathMapValue(i, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j - 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j - 1) is house.wall
                   )
            {
                i = Random.Range(2, layout.getSize() - 2);
                j = Random.Range(2, layout.getSize() - 2);
            }
            worldMap[i, j] = house.unavailable_floor;
            ob.setMapLocation(i, j, size);

            ob.setUpdateable();
            go.gameObject.transform.position = ob.getLocation();
            dict.Add(go, go.GetComponentInChildren <Renderer>());
            activ_list.Add(go);
        }

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("hunger"))
        {
            Debug.Log("hunger");
            ActivityObject ob = go.GetComponent <ActivityObject>();
            ob.setNeed(activities.hunger);
            i = Random.Range(2, layout.getSize() - 2);
            j = Random.Range(2, layout.getSize() - 2);
            while (physicalMap.getpathMapValue(i, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j - 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j - 1) is house.wall)
            {
                i = Random.Range(2, layout.getSize() - 2);
                j = Random.Range(2, layout.getSize() - 2);
            }
            worldMap[i, j] = house.unavailable_floor;
            ob.setMapLocation(i, j, size);

            ob.setUpdateable();
            go.gameObject.transform.position = ob.getLocation();
            dict.Add(go, go.GetComponentInChildren <Renderer>());
            activ_list.Add(go);
        }

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("hygiene"))
        {
            Debug.Log("hygiene");
            ActivityObject ob = go.GetComponent <ActivityObject>();
            ob.setNeed(activities.hygiene);
            i = Random.Range(2, layout.getSize() - 2);
            j = Random.Range(2, layout.getSize() - 2);
            while (physicalMap.getpathMapValue(i, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j - 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j - 1) is house.wall)
            {
                i = Random.Range(2, layout.getSize() - 2);
                j = Random.Range(2, layout.getSize() - 2);
            }
            worldMap[i, j] = house.unavailable_floor;
            ob.setMapLocation(i, j, size);

            ob.setUpdateable();
            go.gameObject.transform.position = ob.getLocation();
            dict.Add(go, go.GetComponentInChildren <Renderer>());
            activ_list.Add(go);
        }

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("energy"))
        {
            Debug.Log("energy");
            ActivityObject ob = go.GetComponent <ActivityObject>();
            ob.setNeed(activities.energy);
            i = Random.Range(2, layout.getSize() - 2);
            j = Random.Range(2, layout.getSize() - 2);
            while (physicalMap.getpathMapValue(i, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j - 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j - 1) is house.wall)
            {
                i = Random.Range(2, layout.getSize() - 2);
                j = Random.Range(2, layout.getSize() - 2);
            }
            worldMap[i, j] = house.unavailable_floor;
            ob.setMapLocation(i, j, size);

            ob.setUpdateable();
            go.gameObject.transform.position = ob.getLocation();
            dict.Add(go, go.GetComponentInChildren <Renderer>());
            activ_list.Add(go);
        }

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("social"))
        {
            Debug.Log("social");
            ActivityObject ob = go.GetComponent <ActivityObject>();
            ob.setNeed(activities.social);
            i = Random.Range(2, layout.getSize() - 2);
            j = Random.Range(2, layout.getSize() - 2);
            while (physicalMap.getpathMapValue(i, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j - 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j - 1) is house.wall)
            {
                i = Random.Range(2, layout.getSize() - 2);
                j = Random.Range(2, layout.getSize() - 2);
            }
            worldMap[i, j] = house.unavailable_floor;
            ob.setMapLocation(i, j, size);

            NPCObject npc = go.GetComponent <NPCObject>();



            ob.setUpdateable();


            go.gameObject.transform.position = ob.getLocation();
            dict.Add(go, go.GetComponentInChildren <Renderer>());
            activ_list.Add(go);
        }

        Debug.Log("all activities" + activ_list.Count);
    }
Beispiel #14
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (_activityObject == null)
            {
                _activityObject             = new ActivityObject();
                _activityObject.ActivityId  = _activity.UniqueID;
                _activityObject.CounterType = cboRule.SelectedIndex.ToString();
            }
            _activityObject.Remark = this.txtActivityName.Text;
            if (counterSignRoleList == null)
            {
                counterSignRoleList = new List <CounterSignRole>();
            }
            CounterSignRole newCondition = new CounterSignRole();

            if (cboUserType.SelectedItem != null)
            {
                newCondition.TypeCode = (cboUserType.SelectedItem as UserType).TypeCode;
                newCondition.TypeName = (cboUserType.SelectedItem as UserType).TypeName;
            }
            else
            {
                ComfirmWindow.ConfirmationBox("提示信息", "用户类型没有出来,请重新选择!", "确定");
                return;
            }
            _activityObject.IsCounterSign = true;
            newCondition.StateCode        = (cboCountersignRoles.SelectedItem as StateType).StateCode;
            if (cbOtherCompany.IsChecked == true)
            {
                newCondition.IsOtherCompany   = true;
                newCondition.OtherCompanyId   = ((cboOtherCompany.SelectedItem) as SMT.Saas.Tools.OrganizationWS.V_COMPANY).COMPANYID;
                newCondition.OtherCompanyName = ((cboOtherCompany.SelectedItem) as SMT.Saas.Tools.OrganizationWS.V_COMPANY).CNAME;
            }
            else
            {
                newCondition.IsOtherCompany   = false;
                newCondition.OtherCompanyId   = "";
                newCondition.OtherCompanyName = "";
            }
            newCondition.StateName = (cboCountersignRoles.SelectedItem as StateType).StateName;

            _activityObject.IsSpecifyCompany = false;
            _activityObject.OtherCompanyId   = "";
            _activityObject.OtherCompanyName = "";
            _activityObject.RoleId           = "";
            _activityObject.RoleName         = "";
            _activityObject.UserType         = "";
            _activityObject.ActivityId       = "State" + _activity.UniqueID;
            _activityObject.CounterType      = cboRule.SelectedIndex.ToString();
            var item = counterSignRoleList.Where(p => p.StateCode == (cboCountersignRoles.SelectedItem as StateType).StateCode).FirstOrDefault();

            if (item == null)
            {
                counterSignRoleList.Add(newCondition);
                dgCountersign.ItemsSource = null;
                dgCountersign.ItemsSource = counterSignRoleList;
            }
            _activityObject.CounterSignRoleList = counterSignRoleList;
            //if (_activityObject.CounterSignRoleList != null && _activityObject.CounterSignRoleList.Count > 0)
            //{//已有角色
            //    if (item == null)
            //    {
            //        counterSignRoleList.Add(newCondition);
            //        dgCountersign.ItemsSource = null;
            //        dgCountersign.ItemsSource = counterSignRoleList;
            //    }
            //}
            //else
            //{//没有角色
            //    counterSignRoleList.Add(newCondition);
            //    _activityObject.CounterSignRoleList = counterSignRoleList;
            //}
            UpdateActivityObject(_activityObject);
            if (this.chkGroupAudit.IsChecked == true)
            {
                this.txtActivityName.Text = "";
                this.txtActivityName.Text = "会签节点";
            }
        }
Beispiel #15
0
 public static BaseObject GetPublisher(this ActivityObject thiz) => thiz?.actor?.items?.FirstOrDefault();
Beispiel #16
0
 private async Task <BaseObject> ReactAndGetSummary(ActivityDeliveryContext ctx, ActivityObject reaction, ReactionType reactionType)
 {
     if (ctx.HasWritten)
     {
         foreach (var target in ctx.item.target.items)
         {
             await _redis.Increment <ReactionsSummaryModel>($"{reactionType}Count", target.id, null);
         }
     }
     return(null);
 }
 public override Task <BaseObject> Post(string index, ActivityObject item)
 {
     throw new NotImplementedException();
 }
Beispiel #18
0
        public bool RegisterActivity(ActivityTypes oActivityType, string sDescription, ActivityObject oObjectID, int iObjectReferenceID, Guid oUserGUID, string sUserName)
        {
            base.AddNew();
            base.ActivityTypeID    = (int)oActivityType;
            base.Description       = sDescription;
            base.ObjectID          = (int)oObjectID;
            base.ObjectReferenceID = iObjectReferenceID;
            base.UserID            = DL_WEB.DAL.Client.User.Instance.GetUserIDByGUID(oUserGUID);
            base.UserName          = sUserName;

            Save();

            return(true);
        }
 public override Task <BaseObject> Set(ActivityObject item, ActivityStreamFilter filter)
 {
     throw new NotImplementedException();
 }
 public abstract Task <BaseObject> Set(ActivityObject item, ActivityStreamFilter filter);
 public abstract Task <BaseObject> Post(string index, ActivityObject item);