Inheritance: MonoBehaviour
コード例 #1
0
 private void Start()
 {
     mage = GetComponent <Mage>();
     //ch = GetComponent<Character>();
     rayCont = GetComponent <RaycastController>();
     cam     = Camera.main.transform;
 }
コード例 #2
0
ファイル: Player.cs プロジェクト: Akisukei/Dinonaut
 // Called before Start
 private void Awake()
 {
     raycastController = GetComponent <RaycastController>();
     spriteRenderer    = GetComponent <SpriteRenderer>();
     animator          = GetComponent <Animator>();
     charSfxPlayer     = GetComponent <DinoSoundPlayer>();
 }
コード例 #3
0
 public void Start()
 {
     //base.Start ();
     rc = GetComponent <RaycastController>();
     rc.Start();
     collisions.faceDir = 1;
 }
コード例 #4
0
 public UnitSelectionController(InputController inputController,
                                RaycastController raycastController, CoordFinder coordFinder)
 {
     this.inputController   = inputController;
     this.raycastController = raycastController;
     this.coordFinder       = coordFinder;
 }
コード例 #5
0
 private void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
 }
コード例 #6
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
コード例 #7
0
    private void Start()
    {
        rcController = new RaycastController(GetComponent <BoxCollider2D>());

        gravity      = -(2 * jumpHeight) / Mathf.Pow(timeToJumpHeight, 2);
        jumpVelocity = (2 * jumpHeight) / timeToJumpHeight;
    }
コード例 #8
0
    // Start is called before the first frame update
    void Start()
    {
        worldSettings = FindObjectOfType <WorldSettings>();
        controller    = GetComponent <CharacterController>();
        worldSettings = FindObjectOfType <WorldSettings>();
        anim          = GetComponent <Animator>();

        raycast = GetComponent <RaycastController>();
        if (raycast != null)
        {
            int inventoryLayerMask = 1 << LayerMask.NameToLayer("Enemy");
            raycast.AddLayerMask(inventoryLayerMask);
        }

        equipper         = GetComponent <ItemEquipper>();
        attack           = GetComponent <PlayerAttack>();
        treeController   = GetComponent <TreeController>();
        cameraAdjuster   = GetComponent <CameraAdjuster>();
        playerStatistics = GetComponent <PlayerStatistics>();
        itemCollector    = GetComponent <ItemCollector>();

        totalSwingTime = GetSwimgTimeByAnimator(anim);

        reticleMissColor = reticle.color;
    }
コード例 #9
0
    /*
     * Resizes the sprite size and the collider size according to the bridge's length
     */
    public void Reload()
    {
        bridge.GetComponent <BoxCollider2D>().size  = new Vector2(length, bridge.GetComponent <BoxCollider2D>().size.y);
        bridge.GetComponent <SpriteRenderer>().size = new Vector2(length, bridge.GetComponent <SpriteRenderer>().size.y);

        bridgeRaycaster = bridge.GetComponentInChildren <RaycastController>();
        bridgeRaycaster.Start();
    }
コード例 #10
0
 private void Awake()
 {
     // -- Cria instância para o próprio objeto
     if (!instance)
     {
         instance = this;
     }
 }
コード例 #11
0
 public CharacterController2D(RaycastController rayController, Transform tran, float maxJump, float minJump, float timetoJump, float MoveSpeed)
 {
     raycastController = rayController;
     _tran             = tran;
     setGravity();
     collisions.faceDir = 1;
     maxJumpHeight      = maxJump; minJumpHeight = minJump; timeToJumpApex = timetoJump; moveSpeed = MoveSpeed;
 }
コード例 #12
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     audio = GetComponent <AudioSource>();
 }
コード例 #13
0
    private void Awake()
    {
        raycastController = GetComponent <RaycastController>();

        if (raycastController == null)
        {
            Debug.LogError("Attach a RaycastController!");
        }
    }
コード例 #14
0
    public void OnClick()
    {
        PuzzleLogic.ResetPuzzle();

        _distance       = RaycastController.GetDistanceToCamera(RaycastController.HitInfo.point);
        _grabLocalPos   = transform.InverseTransformPoint(RaycastController.HitInfo.point);
        _isManipulating = true;

        UIController.ClickManipulatable();
    }
コード例 #15
0
 public UnitDragController(RaycastController raycastController, CoordFinderBySelectedPlayer coordFinderBySelectedPlayer,
                           InputController inputController, UnitSelectionController unitSelectionController,
                           IPredicate <UnitSelectedEvent> canStartDrag)
 {
     this.raycastController           = raycastController;
     this.canStartDrag                = canStartDrag;
     this.coordFinderBySelectedPlayer = coordFinderBySelectedPlayer;
     this.inputController             = inputController;
     this.unitSelectionController     = unitSelectionController;
 }
コード例 #16
0
    protected void Start()
    {
        rcController = new RaycastController(GetComponent <BoxCollider2D>());

        globalWaypoints = new Vector3[localWaypoints.Length];
        for (int i = 0; i < localWaypoints.Length; i++)
        {
            globalWaypoints[i] = localWaypoints[i] + transform.position;
        }
    }
コード例 #17
0
ファイル: Player.cs プロジェクト: shifatkhan/REFract-Unity
 // Called before Start
 private void Awake()
 {
     raycastController = GetComponent <RaycastController>();
     spriteRenderer    = GetComponent <SpriteRenderer>();
     animator          = GetComponent <Animator>();
     rBody             = GetComponent <Rigidbody2D>();
     maxHealth         = health;
     maxStamina        = stamina;
     //charSfxPlayer = GetComponent<DinoSoundPlayer>();
 }
コード例 #18
0
    // Use this for initialization
    void Start()
    {
        rc       = GetComponent <RaycastController> ();
        render   = GetComponent <SpriteRenderer> ();
        animator = GetComponent <Animator> ();

        health = 3;

        //Kinematic formula, solve for acceleration going down
        gravity = -(2 * 2.5f) / Mathf.Pow(0.36f, 2);
    }
コード例 #19
0
    private void Start()
    {
        m_RaycastController = GetComponent <RaycastController> ();

        m_GlobalWaypoints = new Vector3[m_LocalWaypoints.Length];

        for (int i = 0; i < m_LocalWaypoints.Length; i++)
        {
            m_GlobalWaypoints [i] = m_LocalWaypoints [i] + transform.position;
        }
    }
コード例 #20
0
    void Start()
    {
        rbw = whiteBall.GetComponent <Rigidbody>();
        rbr = whiteBall.GetComponent <Rigidbody>();
        rby = whiteBall.GetComponent <Rigidbody>();


        rayCont = GetComponent <RaycastController>();
        gameObject.GetComponent <Rigidbody>();
        //maxspeed =powerSlider.maxValue;
    }
コード例 #21
0
    // Use this for initialization
    void Start()
    {
        rc = GetComponent <RaycastController>();
        rc.Start();

        globalWaypoints = new Vector3[localWaypoints.Length];
        for (int i = 0; i < localWaypoints.Length; i++)
        {
            globalWaypoints[i] = localWaypoints[i] + transform.position;
        }
    }
コード例 #22
0
    public void FixedUpdate()
    {
        if (_isManipulating)
        {
            var target    = RaycastController.GetPosInCenterOfView(_distance);
            var grabPoint = transform.TransformPoint(_grabLocalPos);

            Rigidbody.AddForceAtPosition((target - grabPoint) * ForceMultiplier, grabPoint);
            Rigidbody.AddForceAtPosition(-Rigidbody.GetPointVelocity(grabPoint) * DampingMultiplier, grabPoint);
        }
    }
コード例 #23
0
        /// <summary>
        ///     Get the nearest position that we hit. The layers
        ///     culled are the aiming layers in the camera editor
        /// </summary>
        /// <param name="distance"> The distance to check   </param>
        /// <returns>
        ///     The position of the nearest hit object straight
        ///     from the camera
        /// </returns>
        public RaycastController getNearestStraightLineTarget(float distance)
        {
            RaycastController rayController = new RaycastController(start: transform.position, direction: transform.forward, distance: distance, layerMasks: AimingLayers);

            if (drawRayCasts)
            {
                rayController.DrawRay(c: rayColor);
            }

            return(rayController);
        }
コード例 #24
0
ファイル: Player.cs プロジェクト: alenmemenduf/kitsune
    // Start is called before the first frame update
    void Start()
    {
        controller = GetComponent <RaycastController>();
        renderer   = GetComponent <SpriteRenderer>();

        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);  //Kinematic operatin defining deltaMovement (gravity is treated as acceleartion here)
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;                  //kinematic operation of jump velocity
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);

        timeUntilDash = 0f;
        print("Gravity: " + gravity + " Jump Velocity: " + maxJumpVelocity);
    }
コード例 #25
0
    void Awake()
    {
        movementController = gameObject.GetComponent <MovementController>();
        raycastController  = gameObject.GetComponent <RaycastController>();
        cameraController   = Camera.main.GetComponent <CameraController>();

        //cameraViewsControler = gameObject.GetComponent<CameraViewsControler>();

        SpawnButtons();
        SpawnCameraButton();
        SpawnLevelButtons();
    }
コード例 #26
0
    // Use this for initialization
    void Start()
    {
        boost           = new Boost(currentMovementConfig);
        jump            = new Jump(currentMovementConfig);
        uprightMovement = new UprightMovement(currentMovementConfig);
        airMovement     = new AirMovement(currentMovementConfig);

        raycaster = GetComponent <RaycastController>();
        rb        = GetComponent <Rigidbody>();

        input = FindObjectOfType <InputController>();
    }
コード例 #27
0
        /// <summary>
        ///     Check our bullet moving forward
        /// </summary>
        /// <returns>
        ///     The location of the hit
        /// </returns>
        Vector3 CheckForward()
        {
            var d = bulletRay ? bulletRange : (bulletSpeed * Time.deltaTime);

            RaycastController ray = new RaycastController(start: transform.position,
                                                          direction: transform.forward, distance: d, layerMasks: LayersToHit);

            Vector3 distace = ray.StraightLineHit;

            CheckHit(ray);

            return(distace);
        }
コード例 #28
0
    private void LoadComponents()
    {
        animator     = GetComponent <Animator>();
        particleSys  = GetComponentInChildren <ParticleSystem>();
        audioSources = GetComponents <AudioSource>();
        audioFire    = audioSources[0];
        audioReload  = audioSources[1];
        raycaster    = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <RaycastController>();

        totalBulletCount    = INIT_BULLET_COUNT;
        clipBulletCount     = CLIP_SIZE;
        leftoverBulletCount = totalBulletCount - clipBulletCount;
    }
コード例 #29
0
        /// <summary>
        ///     Check our hit... see if we hit something
        ///     and if we did if that something had a health manager
        ///     attached to it
        /// </summary>
        /// <param name="ray"></param>
        void CheckHit(RaycastController ray)
        {
            if (!ray.FirstObjectHit)
            {
                Destroy(gameObject);
                return;         // we hit nothing
            }

            foreach (RaycastHit hit in ray.OrderedHits)
            {
                if (hit.transform.gameObject.GetComponent <IBulletInteract>() != null)
                {
                    var ibi = hit.transform.GetComponent <IBulletInteract>();
                    if (onHit != null)
                    {
                        onHit.Invoke(false);
                    }

                    if (ibi.OnBulletImpact(this))
                    {
                        break;
                    }
                }
                else if (hit.transform.gameObject.GetComponent <AsteriaHealth.HealthManager>() != null)
                {
                    var healthManager = hit.transform.gameObject.GetComponent <AsteriaHealth.HealthManager>();
                    foreach (RaycastHit hits in ray.OrderedHits)
                    {
                        foreach (AsteriaHealth.HealthItem hi in healthManager.HealthItems)
                        {
                            if (hi.gameObject == hits.collider.gameObject)
                            {
                                if (onHit != null)
                                {
                                    onHit.Invoke(true);
                                }

                                hi.TakeDamage(damage: DoDamage, origin: Owner, hitBy: gameObject);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    createGenericImpactActions();
                    break;
                }
            }
            Destroy(gameObject);
        }
コード例 #30
0
    private void Awake()
    {
        if (player == null)
        {
            player = GameObject.FindGameObjectWithTag("Player");
        }
        _ray       = GetComponent <CharacterController2D>();
        _pathAgent = GetComponent <PathfindingAgent>();

        if (_pathScript == null)
        {
            _pathScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <Pathfinding>();
        }
    }