Esempio n. 1
0
    void OnManArrives(Crowd.Event e)
    {
        var        manArrivedEvent = e as ManArrives;
        GameObject man             = manArrivedEvent.man;
        GameObject obj             = manArrivedEvent.obj;
        int        slotId          = manArrivedEvent.slotId;

        if (obj != null)
        {
            man.GetComponent <CrowdControl>().Flip(obj.GetComponent <PropControl>().changeScaleX);
            man.GetComponent <CrowdControl>().SwitchState(obj.GetComponent <PropControl>().changeState);
            man.transform.SetParent(obj.GetComponent <PropControl>().GetSlotObject(slotId).transform);
            Services.gameEvents.SetCrowdAnimation(man, "busy_forever");
            obj.GetComponent <PropControl>().ReadySlot(slotId, man);

            if (obj.GetComponent <PropControl>().PropFeedbackController != null && obj.GetComponent <PropControl>().IsReady())
            {
                obj.GetComponent <PropControl>().PropFeedbackController.OnStateChange(PropControl.PropState.FULL);
                foreach (PropControl.SlotAttr slot in obj.GetComponent <PropControl>().slots)
                {
                    if (slot.man.GetComponent <CrowdControl>().CrowdFeedbackController != null)
                    {
                        slot.man.GetComponent <CrowdControl>().CrowdFeedbackController.OnStateChange(PropControl.PropState.FULL);
                    }
                }
            }
        }
        else
        {
            man.GetComponent <CrowdControl>().SwitchState(CrowdControl.CrowdState.IDLE);
        }
    }
Esempio n. 2
0
    private void OnDragged(Crowd.Event e)
    {
        ObjectDragEvent ode = (ObjectDragEvent)e;

        transform.localPosition    = Vector3.Lerp(origPos, origPos + posOffset, ode.progress);
        transform.localEulerAngles = Vector3.Lerp(origRot, origRot + rotOffset, ode.progress);
    }
Esempio n. 3
0
    protected void OnRespondRotate(Crowd.Event e)
    {
        if (IsLocked() || IsCoolingDown() || IsActivated())
        {
            return;
        }

        var   clicke = e as RotateEvent;
        float deltaX = clicke.delta.x;

        if (Mathf.Abs(deltaX) < 5f)
        {
            return;
        }

        if (deltaX > 0)
        {
            onRightRotate.Invoke();
        }
        else
        {
            onLeftRotate.Invoke();
        }

        CoolDown();
    }
Esempio n. 4
0
 public FoundPath()
 {
     endEvent   = null;
     endUnit    = null;
     tol        = 0;
     isComplete = false;
 }
Esempio n. 5
0
    private void OnDraggingStairs(Crowd.Event e)
    {
        PropDragEvent de       = (PropDragEvent)e;
        float         deltaRot = step * stairsCount * de.progress;

        for (int i = 0; i < stairsCount; ++i)
        {
            transform.GetChild(i).localEulerAngles = new Vector3(0, step * (stairsCount - i) - deltaRot * (stairsCount - i) / stairsCount, 0);
        }
    }
Esempio n. 6
0
    protected void OnRespondZoom(Crowd.Event e)
    {
        if (IsLocked() || IsCoolingDown() || IsActivated())
        {
            return;
        }

        onRightRotate.Invoke();
        CoolDown();
    }
Esempio n. 7
0
    private void OnCameraAngleChanged(Crowd.Event e)
    {
        CameraAngleEvent ce = (CameraAngleEvent)e;
        float            y  = ce.angle.x;

        if (y > 180)
        {
            y -= 360;
        }
        targetRot = new Vector3(0, y, 0);
    }
Esempio n. 8
0
 private void OnHoldRelease(Crowd.Event e)
 {
     if (isMouseDown)
     {
         isMouseDown = false;
         if (isSnappingBack)
         {
             deltaValue = new Vector3(0, 0, 0);
         }
     }
 }
Esempio n. 9
0
 protected void OnRelease(Crowd.Event e)
 {
     if (isDragging)
     {
         isDragging = false;
         Services.dotweenEvents.ScaleTo(GetComponent <PropFeedbackBehavior>().targetObj.name + " 1, 1, 1, 0.5");
         if (Mathf.Abs(deltaOffset) < Mathf.Abs(dragOffset))
         {
             deltaOffset = 0;
         }
     }
 }
Esempio n. 10
0
    //private void OnRotate(Crowd.Event e)
    //{
    //    RotateEvent re = (RotateEvent)e;
    //    deltaPos += Vector2.Scale(re.delta * 0.01f, new Vector2(isHorizontal ? 1.0f : 0.0f, isVertical ? 1.0f : 0.0f));
    //    deltaPos = new Vector2(
    //        Mathf.Clamp(deltaPos.x, -1, 1),
    //        Mathf.Clamp(deltaPos.y, -1, 1)
    //        );
    //}

    private void OnZoom(Crowd.Event e)
    {
        if (willZoomWithCamera)
        {
            ZoomEvent ze = (ZoomEvent)e;
            if (ze.delta > 0)
            {
                Services.dotweenEvents.ScaleTo(gameObject.name + " " + zoomScale.ToString() + " " + zoomScale.ToString() + " " + zoomScale.ToString() + " 1");
            }
            else
            if (ze.delta < 0)
            {
                Services.dotweenEvents.ScaleTo(gameObject.name + " 1, 1, 1, 1");
            }
        }
    }
Esempio n. 11
0
    protected void OnRespondClick(Crowd.Event e)
    {
        if (IsLocked() || IsCoolingDown() || IsActivated())
        {
            return;
        }

        var        clicke = e as ClickEvent;
        GameObject obj    = clicke.mouseClickObj;
        Vector3    pos    = clicke.mouseClickPos;

        if (Vector3.Distance(transform.position, pos) < maxClickRange)
        {
            onClick.Invoke();
            CoolDown();
        }
    }
Esempio n. 12
0
    void OnManLeavesFromObj(Crowd.Event e)
    {
        var        manLeftFromEvent = e as ManLeavesFromObj;
        GameObject man    = manLeftFromEvent.man;
        GameObject obj    = manLeftFromEvent.obj;
        int        slotId = manLeftFromEvent.slotId;

        if (obj == null)
        {
            obj    = man.GetComponent <CrowdControl>().GetWorkingObject();
            slotId = man.GetComponent <CrowdControl>().GetWorkingSlot();
        }

        if (obj == null || slotId == -1)
        {
            return;
        }

        //Debug.Log(man + " " + obj);
        man.transform.SetParent(Services.menParentObj.transform);
        man.GetComponent <CrowdControl>().SetWorkingObject(null, -1);
        Services.gameEvents.ClearCrowdAnimation(man, "busy_forever");
        obj.GetComponent <PropControl>().FreeSlot(slotId);

        if (man.GetComponent <CrowdControl>().CrowdFeedbackController != null)
        {
            man.GetComponent <CrowdControl>().CrowdFeedbackController.OnStateChange(PropControl.PropState.EMPTY);
        }

        if (obj.GetComponent <PropControl>().PropFeedbackController != null)
        {
            if (obj.GetComponent <PropControl>().IsEmpty())
            {
                obj.GetComponent <PropControl>().PropFeedbackController.OnStateChange(PropControl.PropState.EMPTY);
            }
            else
            {
                obj.GetComponent <PropControl>().PropFeedbackController.OnStateChange(PropControl.PropState.NOTFULL);
            }
        }

        man.GetComponent <CrowdControl>().SwitchState(CrowdControl.CrowdState.IDLE);
    }
Esempio n. 13
0
    void OnManLeavesForObj(Crowd.Event e)
    {
        var        manLeftForEvent = e as ManLeavesForObj;
        GameObject man             = manLeftForEvent.man;
        GameObject obj             = manLeftForEvent.obj;
        int        slotId          = manLeftForEvent.slotId;

        man.GetComponent <CrowdControl>().SetWorkingObject(obj, slotId);
        obj.GetComponent <PropControl>().PlanSlot(man, slotId);

        if (man.GetComponent <CrowdControl>().CrowdFeedbackController != null)
        {
            man.GetComponent <CrowdControl>().CrowdFeedbackController.Breathe();
        }
        if (obj.GetComponent <PropControl>().PropFeedbackController != null)
        {
            obj.GetComponent <PropControl>().PropFeedbackController.Breathe();
        }
    }
Esempio n. 14
0
    private void OnUpdate(Crowd.Event e)
    {
        if (willMoveHorizontally || willMoveVertically)
        {
            ParallaxScrollingEvent pe = (ParallaxScrollingEvent)e;
            Vector2 value             = pe.scrollValue;

            float newX = rect.anchoredPosition.x;
            if (willMoveHorizontally && horizontalRange.x <= value.x && value.x <= horizontalRange.y)
            {
                //Debug.Log(gameObject.name + " " + (value.x - horizontalRange.x) / (horizontalRange.y - horizontalRange.x));
                newX = Mathf.Lerp(horizontalOffset.x, horizontalOffset.y, (value.x - horizontalRange.x) / (horizontalRange.y - horizontalRange.x));
            }

            float newY = rect.anchoredPosition.y;
            if (willMoveVertically && verticalRange.x <= value.y && value.y <= verticalRange.y)
            {
                newY = Mathf.Lerp(verticalOffset.x, verticalOffset.y, (value.y - verticalRange.x) / (verticalRange.y - verticalRange.x));
            }

            rect.anchoredPosition = new Vector2(newX, newY);
        }
    }
Esempio n. 15
0
    public virtual void Move(GameObject actor, float posTol, Crowd.Event endEvent)
    {
        if (recentPath == null || !recentPath.isComplete)
        {
            return;
        }

        //Vector3 lastUnitPos = recentPath.LastUnitPos();
        //Vector3 lastUnitOrientation = recentPath.LastUnitOrientation(actor.transform.position);

        //Services.footprintsManager.Take(lastUnitPos, lastUnitOrientation);

        recentPath.endEvent = endEvent;
        recentPath.tol      = posTol;
        if (pathTable.ContainsKey(actor))
        {
            // should abort original path
            pathTable.Remove(actor);
        }

        pathTable.Add(actor, recentPath);
        //recentPath = null;
    }
Esempio n. 16
0
 public override void Move(GameObject actor, float posTol, Crowd.Event endEvent = null)
 {
     base.Move(actor, posTol, endEvent);
 }
Esempio n. 17
0
    private void OnDragging(Crowd.Event e)
    {
        PropDragEvent de = (PropDragEvent)e;

        animationProgress = de.progress * 3;
    }
Esempio n. 18
0
 public FeedbackTask(Crowd.Event e)
 {
     Debug.Log("feed back ");
     Feedback = e;
 }