Exemplo n.º 1
0
    public bool HeavyDamage(int damage, Vector3 origin)
    {
        if (status.Invincible())
        {
            return(false);
        }

        if (StateCompare(MarioStates.Knockback) || StateCompare(MarioStates.KnockbackForwards) || StateCompare(MarioStates.TeleportIn) || StateCompare(MarioStates.TeleportOut))
        {
            return(false);
        }

        Vector3 direction = Math3d.ProjectVectorOnPlane(controller.up, origin - transform.position).normalized;

        if (direction == Vector3.zero)
        {
            direction = lookDirection;
        }

        bool forward = Vector3.Angle(direction, lookDirection) < 90;

        if (Airborn())
        {
            if (forward)
            {
                moveSpeed    = -3.0f;
                currentState = MarioStates.AirKnockback;
            }
            else
            {
                moveSpeed    = 3.0f;
                currentState = MarioStates.AirKnockbackForwards;
            }
        }
        else
        {
            if (forward)
            {
                currentState = MarioStates.Knockback;
                moveSpeed    = -3.0f;
            }
            else
            {
                currentState = MarioStates.KnockbackForwards;
                moveSpeed    = 3.0f;
            }
        }

        lookDirection = forward ? direction : -direction;

        SmartCamera.Shake(1.6f, 25.0f, 0.5f);

        sound.PlayTakeDamage();

        Instantiate(TakeDamageEffect, transform.position + controller.up * controller.height * 0.6f, Quaternion.identity);

        status.TakeDamage(damage);

        return(true);
    }
 private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     SmartCamera.Closing();
     SafetySystem.Closing();
     RemoteTerminal.Closing();
     RobotSimulator.Closing();
 }
Exemplo n.º 3
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Exemplo n.º 4
0
    /* Smoothly moves the camera to a new point
     *
     * Referenced Unity's documentation on Vector3.Slerp
     * https://docs.unity3d.com/ScriptReference/Vector3.Slerp.html
     */
    public IEnumerator MoveCamera(CameraMoveParams camParams)
    {
        camIsMoving = true;
        float start = Time.time;

        if (smartCam == null)
        {
            smartCam = Camera.main.gameObject.GetComponent <SmartCamera>();
        }
        Vector3    startPos     = smartCam.transform.position;
        Quaternion startRot     = smartCam.transform.rotation;
        float      fracComplete = 0;

        while (fracComplete < 1)
        {
            // slerp between the positions
            fracComplete = ((Time.time - start) * camParams.speed) / Vector3.Distance(startPos, camParams.destination);
            smartCam.SetPR(
                Vector3.Slerp(startPos, camParams.destination, fracComplete),
                Quaternion.Slerp(startRot, camParams.rotation, fracComplete));

            yield return(null);
        }
        camIsMoving = false;
        yield break;
    }
Exemplo n.º 5
0
 // Start is called before the first frame update
 void Start()
 {
     _smartCam       = Camera.main.GetComponent <SmartCamera>();
     camFollowOffset =
         (transform.forward * offsetZ) +
         (transform.right * offsetX) +
         (transform.up * offsetY);
 }
Exemplo n.º 6
0
 void Start()
 {
     player      = FindObjectOfType <Player>();
     smartCamera = FindObjectOfType <SmartCamera>();
     mainCamera  = smartCamera.GetComponent <Camera>();
     ground      = FindObjectOfType <Ground>();
     Physics.IgnoreLayerCollision(player.gameObject.layer, player.gameObject.layer, true);
     Physics.IgnoreLayerCollision(player.gameObject.layer, 11, true);
 }
Exemplo n.º 7
0
    /* Camera follow */
    void CameraFollow()
    {
        if (_smartCam == null)
        {
            _smartCam = Camera.main.GetComponent <SmartCamera>();
        }

        Vector3 desiredPosition = gameObject.transform.position + camFollowOffset;

        _smartCam.LookAt(gameObject.transform.position);
        _smartCam.SetPosition(Vector3.Slerp(_smartCam.transform.position, desiredPosition, cameraFollowDelay));
    }
Exemplo n.º 8
0
 private new void Awake()
 {
     base.Awake();
     smartCamera = GetComponentInChildren <SmartCamera>();
     if ((captureRGB || captureDepth || captureSemanticMask) && smartCamera == null)
     {
         captureRGB          = false;
         captureDepth        = false;
         captureSemanticMask = false;
         Log("Smart camera not found", LogLevel.Error, true);
     }
     laserScan = GetComponentInChildren <LaserScanner>();
     if (captureScan && laserScan == false)
     {
         captureScan = false;
         Log("Laser not found", LogLevel.Error, true);
     }
     lidar = GetComponentInChildren <Lidar>();
     if (captureLidar && lidar == null)
     {
         captureLidar = false;
         Log("Lidar not found", LogLevel.Error, true);
     }
 }
Exemplo n.º 9
0
    public bool GroundDamageLight(int damage, Vector3 origin, float pushbackSpeed, bool canHurtInAir = true)
    {
        if (status.Invincible())
        {
            return(false);
        }

        if (StateCompare(MarioStates.Stagger) || StateCompare(MarioStates.TeleportIn) || StateCompare(MarioStates.TeleportOut))
        {
            return(false);
        }

        if (!canHurtInAir && Airborn())
        {
            return(false);
        }

        if (StateCompare(MarioStates.Slide))
        {
            if (Mathf.Abs(moveSpeed) > 3.0f)
            {
                return(false);
            }
        }

        status.TakeDamage(damage);

        Vector3 direction = Math3d.ProjectVectorOnPlane(controller.up, origin - transform.position).normalized;

        if (direction == Vector3.zero)
        {
            direction = lookDirection;
        }

        staggerForward = Vector3.Angle(direction, lookDirection) < 90;

        if (Airborn())
        {
            if (staggerForward)
            {
                moveSpeed    = -3.0f;
                currentState = MarioStates.AirKnockback;
            }
            else
            {
                moveSpeed    = 3.0f;
                currentState = MarioStates.AirKnockbackForwards;
            }
        }
        else
        {
            if (status.CurrentHealth == 0)
            {
                if (staggerForward)
                {
                    currentState = MarioStates.Knockback;
                    moveSpeed    = -3.0f;
                }
                else
                {
                    currentState = MarioStates.KnockbackForwards;
                    moveSpeed    = 3.0f;
                }
            }
            else
            {
                currentState = MarioStates.Stagger;

                moveSpeed = staggerForward ? -pushbackSpeed : pushbackSpeed;
            }
        }

        Instantiate(TakeDamageEffect, transform.position + controller.up * controller.height * 0.6f, Quaternion.identity);

        sound.PlayTakeDamage();

        lookDirection = staggerForward ? direction : -direction;

        SmartCamera.Shake(0.85f, 15.0f, 0.5f);

        return(true);
    }
Exemplo n.º 10
0
 public FollowState(SmartCamera content)
     : base(content, FSMStateType.Follow)
 {
 }
Exemplo n.º 11
0
 public FSMState(SmartCamera content, FSMStateType type)
     : base(content)
 {
     _stateType = type;
 }
Exemplo n.º 12
0
 public SideScrollingState(SmartCamera content)
     : base(content, FSMStateType.SideScrolling)
 {
 }
Exemplo n.º 13
0
 void Awake()
 {
     smartCam = Camera.main.gameObject.GetComponent <SmartCamera>();
 }
Exemplo n.º 14
0
 public StayState(SmartCamera content)
     : base(content, FSMStateType.Stay)
 {
 }
Exemplo n.º 15
0
 void Start()
 {
     me = this;
     ResetTargetHolder();
     SelectionManager.UnitTargetedEvent += OnUnitTargeted;
 }