コード例 #1
0
    private void Execute(AvailableAction _currentAction)
    {
        switch (_currentAction._action)
        {
        case PossibleAction.Action_TurnCorner:
        {
            if (canMove)
            {
                TurnCorner(_currentAction);
            }
            break;
        }

        case PossibleAction.Action_EnterShop:
        {
            if (canMove)
            {
                CanMove(false);
                CanExecuteAction(false);
                StartCoroutine(EnterShop(_currentAction));
            }
            break;
        }

        case PossibleAction.Action_ExitShop:
        {
            if (canExecuteAction)
            {
                StartCoroutine(ExitShop(_currentAction));
            }

            break;
        }

        case PossibleAction.Action_CrossStreet:
        {
            if (canMove)
            {
                if (currentCrosswalk.currentCWState == CrossWalk.CrosswalkState.CWS_Red)
                {
                    if (onJayWalking != null)
                    {
                        onJayWalking();
                    }
                }

                canMove = false;
                StartCoroutine(CrossStreet(_currentAction));
            }
            break;
        }

        case PossibleAction.Action_Talk:
        {
            Talk();
            break;
        }
        }
    }
コード例 #2
0
        public void ReadJson(AvailableAction expected, string json)
        {
            var converter = AvailableActionsConverter.Instance;

            using (var stringReader = new StringReader(json))
                using (var jsonReader = new JsonTextReader(stringReader))
                {
                    Assert.Equal(expected, converter.ReadJson(jsonReader, null, None, false, NewtonsoftJsonSerializer.Deserializer));
                }
        }
コード例 #3
0
 private void OnGUI()
 {
     if (Event.current.type == EventType.KeyDown)
     {
         AvailableAction currentAction = currentAvailableActions.Find(aa => aa._actionKey == Event.current.keyCode);
         if (currentAction != null)
         {
             Execute(currentAction);
         }
     }
 }
コード例 #4
0
    private void TurnCorner(AvailableAction _currentAction)
    {
        GameObject newCamPoint = _currentAction.triggerObj.GetComponent <CornerTrigger> ().SwitchCameraPoint();

        myCamera.gameObject.GetComponent <CameraScript> ().MoveTransition(newCamPoint);
        transform.eulerAngles = new Vector3(transform.eulerAngles.x, newCamPoint.transform.eulerAngles.y, newCamPoint.transform.eulerAngles.z);

        Vector3 targetPos = _currentAction.triggerObj.transform.position;

        targetPos.y        = transform.position.y;
        transform.position = targetPos;
    }
コード例 #5
0
    private IEnumerator CrossStreet(AvailableAction _currentAction)
    {
        myRigidbody.velocity = Vector3.zero;
        GameObject newCamPoint = _currentAction.triggerObj.GetComponent <CornerTrigger> ().SwitchCameraPoint();

        myCamera.gameObject.GetComponent <CameraScript> ().MoveTransition(newCamPoint);
        transform.eulerAngles = new Vector3(transform.eulerAngles.x, newCamPoint.transform.eulerAngles.y, newCamPoint.transform.eulerAngles.z);

        Vector3 targetVec = _currentAction.triggerObj.transform.position + _currentAction.triggerObj.transform.forward * _currentAction.triggerObj.GetComponent <CornerTrigger>().distanceToCross;

        targetVec.y = transform.position.y;

        while (Vector3.Distance(transform.position, targetVec) > 0.5f)
        {
            transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.5f);
            if (isBeingApprehended)
            {
                yield return(new WaitForSeconds(0.25f));

                break;
            }
            yield return(null);
        }

        if (isBeingApprehended)
        {
            newCamPoint = _currentAction.triggerObj.GetComponent <CornerTrigger> ().SwitchCameraPoint();
            myCamera.gameObject.GetComponent <CameraScript> ().MoveTransition(newCamPoint);
            transform.eulerAngles = new Vector3(transform.eulerAngles.x, newCamPoint.transform.eulerAngles.y, newCamPoint.transform.eulerAngles.z);
            targetVec             = _currentAction.triggerObj.transform.position;
            targetVec.y           = transform.position.y;
            while (Vector3.Distance(transform.position, targetVec) > 0.5f)
            {
                transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.5f);
                yield return(null);
            }

            yield return(new WaitForSeconds(7.5f));

            isBeingApprehended = false;
        }

        canMove = true;
        yield return(null);
    }
コード例 #6
0
    private IEnumerator EnterShop(AvailableAction _currentAction)
    {
        Manager_GameTime.Instance.PauseGameTime(true);
        myRigidbody.velocity = Vector3.zero;
        currentAvailableActions.Remove(currentAvailableActions.Find(aa => aa._action == PossibleAction.Action_EnterShop));
        Vector3 targetVec = _currentAction.triggerObj.transform.position + _currentAction.triggerObj.transform.forward * 3.0f;

        targetVec.y = transform.position.y;

        while (Vector3.Distance(transform.position, targetVec) > 0.15f)
        {
            transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.45f);
            yield return(null);
        }

        _currentAction.triggerObj.GetComponent <Building_Script> ().StartDialogue(portrait, playerName, playerLastName);
        _currentAction.triggerObj.GetComponent <Building_Script> ().ApplyEventMethods();
        currentAvailableActions.Add(new AvailableAction(PossibleAction.Action_ExitShop, KeyCode.S, _currentAction.triggerObj));
    }
コード例 #7
0
    private IEnumerator ExitShop(AvailableAction _currentAction)
    {
        _currentAction.triggerObj.GetComponent <Building_Script> ().RemoveEventMethods();
        Manager_GameTime.Instance.PauseGameTime(false);
        Manager_GameTime.Instance.TimeLeap(1, 20, 0);
        myRigidbody.velocity = Vector3.zero;
        currentAvailableActions.Remove(currentAvailableActions.Find(aa => aa._action == PossibleAction.Action_ExitShop));
        Vector3 targetVec = _currentAction.triggerObj.transform.position + _currentAction.triggerObj.transform.forward * -0.25f;

        targetVec.y = transform.position.y;

        while (Vector3.Distance(transform.position, targetVec) > 0.15f)
        {
            transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.45f);
            yield return(null);
        }

        CanMove(true);
        //		currentAvailableActions.Add (new AvailableAction (PossibleAction.Action_ExitShop, KeyCode.S, _currentAction.triggerObj));
    }
コード例 #8
0
    private IEnumerator CrossStreet(AvailableAction _currentAction)
    {
        myRigidbody.velocity = Vector3.zero;
        GameObject newCamPoint =  _currentAction.triggerObj.GetComponent<CornerTrigger> ().SwitchCameraPoint ();
        myCamera.gameObject.GetComponent<CameraScript> ().MoveTransition (newCamPoint);
        transform.eulerAngles = new Vector3 (transform.eulerAngles.x, newCamPoint.transform.eulerAngles.y, newCamPoint.transform.eulerAngles.z);

        Vector3 targetVec = _currentAction.triggerObj.transform.position + _currentAction.triggerObj.transform.forward * _currentAction.triggerObj.GetComponent<CornerTrigger>().distanceToCross;
        targetVec.y = transform.position.y;

        while(Vector3.Distance(transform.position, targetVec) > 0.5f)
        {
            transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.5f);
            if(isBeingApprehended)
            {
                yield return new WaitForSeconds(0.25f);
                break;
            }
            yield return null;
        }

        if(isBeingApprehended)
        {
            newCamPoint =  _currentAction.triggerObj.GetComponent<CornerTrigger> ().SwitchCameraPoint ();
            myCamera.gameObject.GetComponent<CameraScript> ().MoveTransition (newCamPoint);
            transform.eulerAngles = new Vector3 (transform.eulerAngles.x, newCamPoint.transform.eulerAngles.y, newCamPoint.transform.eulerAngles.z);
            targetVec = _currentAction.triggerObj.transform.position;
            targetVec.y = transform.position.y;
            while(Vector3.Distance(transform.position, targetVec) > 0.5f)
            {
                transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.5f);
                yield return null;
            }

            yield return new WaitForSeconds(7.5f);
            isBeingApprehended = false;
        }

        canMove = true;
        yield return null;
    }
コード例 #9
0
        public static List <AvailableAction> BuildAvailableActionsAlwaysStand()
        {
            var availableActions = new List <AvailableAction>();

            for (int d = 2; d <= 11; d++)
            {
                for (int p = 3; p <= 21; p++)
                {
                    var action = new AvailableAction()
                    {
                        DealerCard   = d,
                        PlayerValue  = p,
                        PlayerAction = PlayerAction.Stand,
                        Key          = Guid.NewGuid()
                    };
                    availableActions.Add(action);
                }
            }

            return(availableActions);
        }
コード例 #10
0
    private void TurnCorner(AvailableAction _currentAction)
    {
        GameObject newCamPoint =  _currentAction.triggerObj.GetComponent<CornerTrigger> ().SwitchCameraPoint ();
        myCamera.gameObject.GetComponent<CameraScript> ().MoveTransition (newCamPoint);
        transform.eulerAngles = new Vector3 (transform.eulerAngles.x, newCamPoint.transform.eulerAngles.y, newCamPoint.transform.eulerAngles.z);

        Vector3 targetPos = _currentAction.triggerObj.transform.position;
        targetPos.y = transform.position.y;
        transform.position = targetPos;
    }
コード例 #11
0
    private IEnumerator ExitShop(AvailableAction _currentAction)
    {
        _currentAction.triggerObj.GetComponent<Building_Script> ().RemoveEventMethods ();
        Manager_GameTime.Instance.PauseGameTime (false);
        Manager_GameTime.Instance.TimeLeap (1, 20, 0);
        myRigidbody.velocity = Vector3.zero;
        currentAvailableActions.Remove(currentAvailableActions.Find(aa => aa._action == PossibleAction.Action_ExitShop));
        Vector3 targetVec = _currentAction.triggerObj.transform.position + _currentAction.triggerObj.transform.forward * -0.25f;
        targetVec.y = transform.position.y;

        while(Vector3.Distance(transform.position, targetVec) > 0.15f)
        {
            transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.45f);
            yield return null;
        }

        CanMove (true);
        //		currentAvailableActions.Add (new AvailableAction (PossibleAction.Action_ExitShop, KeyCode.S, _currentAction.triggerObj));
    }
コード例 #12
0
    private void Execute(AvailableAction _currentAction)
    {
        switch(_currentAction._action)
        {
        case PossibleAction.Action_TurnCorner:
        {
            if(canMove)
                TurnCorner(_currentAction);
            break;
        }
        case PossibleAction.Action_EnterShop:
        {
            if(canMove)
            {
                CanMove(false);
                CanExecuteAction(false);
                StartCoroutine(EnterShop (_currentAction));
            }
            break;
        }
        case PossibleAction.Action_ExitShop:
        {
            if(canExecuteAction)
                StartCoroutine(ExitShop (_currentAction));

            break;
        }
        case PossibleAction.Action_CrossStreet:
        {
            if(canMove)
            {
                if(currentCrosswalk.currentCWState == CrossWalk.CrosswalkState.CWS_Red)
                {
                    if(onJayWalking != null)
                        onJayWalking();
                }

                canMove = false;
                StartCoroutine (CrossStreet(_currentAction));
            }
            break;
        }
        case PossibleAction.Action_Talk:
        {
            Talk();
            break;
        }
        }
    }
コード例 #13
0
    private IEnumerator EnterShop(AvailableAction _currentAction)
    {
        Manager_GameTime.Instance.PauseGameTime (true);
        myRigidbody.velocity = Vector3.zero;
        currentAvailableActions.Remove(currentAvailableActions.Find(aa => aa._action == PossibleAction.Action_EnterShop));
        Vector3 targetVec = _currentAction.triggerObj.transform.position + _currentAction.triggerObj.transform.forward * 3.0f;
        targetVec.y = transform.position.y;

        while(Vector3.Distance(transform.position, targetVec) > 0.15f)
        {
            transform.position = Vector3.Lerp(transform.position, targetVec, Time.deltaTime * moveSpeed * 0.45f);
            yield return null;
        }

        _currentAction.triggerObj.GetComponent<Building_Script> ().StartDialogue (portrait, playerName, playerLastName);
        _currentAction.triggerObj.GetComponent<Building_Script> ().ApplyEventMethods ();
        currentAvailableActions.Add (new AvailableAction (PossibleAction.Action_ExitShop, KeyCode.S, _currentAction.triggerObj));
    }