void Start()
 {
     rb         = GetComponent <Rigidbody>();
     mainCamera = FindObjectOfType <Camera>();
     bow        = GetComponent <BowController>();
     canFire    = true;
 }
示例#2
0
    public void Start()
    {
        playerStats = GetComponentInParent <PlayerGameplayValues>();

        controllerBehaviour = transform.parent.GetComponent <ControllerBehaviour>();
        healthBehaviour     = transform.parent.GetComponent <HealthBehaviour>();
        bowController       = transform.parent.GetComponent <BowController>();
    }
示例#3
0
文件: Player.cs 项目: jjokin/unity
    //public GameObject otherGameObject;

    void Start()
    {
        controller = GetComponent <PlayerController>();
        // controller = otherGameObject.GetComponent<PlayerController>();
        viewCamera    = Camera.main;
        bowController = GetComponent <BowController>();
        Debug.Log("pelaaja valmiina");
    }
示例#4
0
 private void Initialize()
 {
     if (baseBow == null)
     {
         baseBow  = gameObject;
         baseBowC = gameObject.GetComponent <BowController>();
         var greatbow = Instantiate(gameObject, transform.position, transform.rotation, transform.parent);
         greatbow.AddComponent <GreatBow>();
     }
 }
示例#5
0
 void Start()
 {
     tpc                  = GameManager.instance.tpc;
     altOS                = GameManager.instance.altOS;
     hookshot             = GetComponent <HookshotController>();
     hookshot.altweapons  = this;
     boomerang            = GetComponent <BoomerangController>();
     boomerang.altweapons = this;
     bow                  = GetComponent <BowController>();
     bow.altweapons       = this;
 }
    // Use this for initialization
    void Start()
    {
        rgbd2D = GetComponent <Rigidbody2D>();

        arrowInitialPosition = transform.position;
        //arrowInitialRotation = transform.rotation;

        parent        = GameObject.Find("Bow");
        arrowHead     = transform.GetChild(0).gameObject;
        bowController = this.transform.parent.gameObject.GetComponent <BowController>();
    }
示例#7
0
    // Use this for initialization
    void Start()
    {
        // if (team == team1)
        //  target = team2[n].transform;
        target = GameObject.FindGameObjectWithTag("Player").transform;

        bowcontroller = GetComponent <BowController>();
        //alaisia alussa 0
        subnum = 0;

        // EnemyRigidbody = GetComponent<Rigidbody>();
        // enemyposition = transform.position;
    }
示例#8
0
 public override void SetupAfterLoad(int index)
 {
     base.SetupAfterLoad(index);
     if (this.m_Loaded)
     {
         if (BowController.Get().IsActive())
         {
             BowController.Get().SetArrow(this);
             return;
         }
         InventoryBackpack.Get().InsertItem(this, null, null, true, true, true, true, true);
     }
 }
示例#9
0
    private void Start()
    {
        myRigid    = GetComponent <Rigidbody>();
        myCollider = GetComponent <CapsuleCollider>();
        anim       = GetComponent <Animator>();

        // Weapon
        rifleController       = GetComponent <RifleController>();
        baseballBatController = GetComponent <BaseballBatController>();
        bowController         = GetComponent <BowController>();

        // viewCamera = Camera.main; // 메인카메라
    }
示例#10
0
 public void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <BowController>() != null)
     {
         BowController        otherController       = other.GetComponent <BowController>();
         PlayerGameplayValues otherControllerValues = other.GetComponent <PlayerGameplayValues>();
         if (otherController.numberOfBullets < otherControllerValues.magazineSize)
         {
             SoundManager.instance.PlayArrowTake();
             otherController.numberOfBullets++;
             Destroy(Arrow);
         }
     }
 }
示例#11
0
 void Start()
 {
     //Instantiate required object components
     sfxMan      = FindObjectOfType <SFXManager>();      //So our player can play sound effects
     anim        = GetComponent <Animator>();            //So our player can animate
     anim.speed  = 2;
     myRigidbody = GetComponent <Rigidbody2D>();         //So our player can use physics
     thePHM      = GetComponent <PlayerHealthManager>(); //So our player can get hurt or healed or die
     //Make sure our player canMove if for some reason they can't at the start of the scene
     canMove = true;
     //Default to having our player face down
     lastMove = new Vector2(0, -1f);        //Have our player spawn in facing down
     talking  = false;
     OurBow   = Bow.GetComponent <BowController>();
     Weapon   = WeaponType.Bow;
 }
示例#12
0
    public void Start()
    {
        bowController       = GetComponent <BowController>();
        controllerBehaviour = GetComponent <ControllerBehaviour>();
        //if premiere partie et jamais joué avant
        print(scriptableStats);
        maxHealth    = scriptableStats.maxHealth.startValue;
        healthRegen  = scriptableStats.healthRegen.startValue;
        speed        = scriptableStats.speed.startValue;
        magazineSize = scriptableStats.maxAmmo.startValue;
        numberOfArrowStartingGame = scriptableStats.startAmmo.startValue;
        maxStamina   = scriptableStats.maxStamina.startValue;
        staminaRegen = scriptableStats.staminaRegen.startValue;


        health  = maxHealth;
        stamina = maxStamina;
    }
示例#13
0
        private void Start()
        {
            bc       = GetComponent <BowController>();
            instance = gameObject;
            try
            {
                var bow = transform.Find("Bow");
                if (bow == null)
                {
                    ModAPI.Log.Write("Bow is null");
                }
                Destroy(transform.Find("TapedLight").gameObject);
                //if (modelPrefab == null) modelPrefab = Res.ResourceLoader.GetAssetBundle(2004).LoadAsset<GameObject>("firebow.prefab");
                //model = Instantiate(modelPrefab);
                model = new GameObject();
                model.transform.parent        = bow.parent;
                model.transform.localScale    = Vector3.one * 1.5f;
                model.transform.localPosition = new Vector3(0, 0, 0.3f);
                model.transform.localRotation = Quaternion.Euler(0, 180, 0);

                model.AddComponent <MeshFilter>().mesh       = Res.ResourceLoader.instance.LoadedMeshes[167];
                model.AddComponent <MeshRenderer>().material =
                    Core.CreateMaterial(new BuildingData()
                {
                    BumpMap     = Res.ResourceLoader.GetTexture(168),
                    BumpScale   = 1.4f,
                    Metalic     = 0.6f,
                    Smoothness  = 0.6f,
                    MainTexture = Res.ResourceLoader.GetTexture(169),
                    EmissionMap = Res.ResourceLoader.GetTexture(169),
                });

                Destroy(bow.gameObject);
                model.transform.localScale *= 1.1f;
            }
            catch (System.Exception e)
            {
                ModAPI.Log.Write(e.Message);
            }
        }
    void Start()
    {
        playerStats = GetComponent <PlayerGameplayValues>();

        data.myRigidbody = GetComponent <Rigidbody>();
        bowController    = GetComponent <BowController>();
        lineRenderer     = GetComponent <LineRenderer>();

        //setup line renderer
        lineRenderer.startWidth = 0.5f;
        lineRenderer.endWidth   = 0.5f;
        lineRenderer.SetPosition(0, bowController.data.firePoint.position);

        lineRenderer.SetPosition(1, transform.forward * data.lineRange);

        if (data.playerID == "_0")
        {
            GameManagerValues.instance.Player1 = this;
        }
        else
        {
            GameManagerValues.instance.Player2 = this;
        }
    }
 public PlayerController GetLocalActiveControllerAnimClipReplacer()
 {
     if (BowController.Get().enabled)
     {
         return(BowController.Get());
     }
     if (HeavyObjectController.Get().enabled)
     {
         return(HeavyObjectController.Get());
     }
     if (ItemController.Get().enabled)
     {
         return(ItemController.Get());
     }
     if (WeaponMeleeController.Get().enabled)
     {
         return(WeaponMeleeController.Get());
     }
     if (WeaponSpearController.Get().enabled)
     {
         return(WeaponSpearController.Get());
     }
     return(null);
 }
示例#16
0
 protected override void Awake()
 {
     base.Awake();
     BowController = GetComponentInChildren <BowController>();
 }
示例#17
0
 internal void setParent(BowController bowController)
 {
     this.bowController = bowController;
 }
示例#18
0
    private void UpdateWantedSpeed()
    {
        if (!this.IsActive() || (FreeHandsLadderController.Get().IsActive() && !this.m_JumpInProgress))
        {
            this.m_WantedSpeed.Reset();
            this.m_SlidingSpeedSoft.Reset();
            this.m_SlideDir         = Vector3.zero;
            this.m_CurentMoveSpeed  = 0f;
            this.m_CurrentMoveSpeed = MoveSpeed.Idle;
            return;
        }
        Vector2 vector = new Vector2(this.m_Inputs.m_Horizontal, this.m_Inputs.m_Vertical);

        if (vector.sqrMagnitude > 1f)
        {
            vector.Normalize();
        }
        bool  flag  = (this.m_CollisionFlags & CollisionFlags.Below) == CollisionFlags.None;
        bool  flag2 = !flag && (this.m_CollisionFlagsAddSpeed & CollisionFlags.Below) == CollisionFlags.None;
        bool  flag3 = this.m_Inputs.m_Sprint;
        float num   = 0f;

        this.m_CurrentMoveSpeed = MoveSpeed.Idle;
        bool flag4 = this.m_Player && this.m_Player.GetMovesBlocked();

        if (this.m_RunDepletedStamina)
        {
            if (flag3)
            {
                flag3 = false;
            }
            else
            {
                this.m_RunDepletedStamina = false;
            }
        }
        if (BowController.Get().m_MaxAim)
        {
            flag3 = false;
        }
        if (flag3 && this.m_RunBlocked)
        {
            flag3 = false;
        }
        if (!flag4 && vector.magnitude > 0.5f)
        {
            if (flag3)
            {
                if (vector.y < -0.5f)
                {
                    num = this.m_BackwardWalkSpeed;
                    this.m_CurrentMoveSpeed = MoveSpeed.Walk;
                }
                else
                {
                    num = this.m_RunSpeed;
                    this.m_CurrentMoveSpeed = MoveSpeed.Run;
                }
            }
            else if (vector.magnitude > 0.5f)
            {
                num = ((vector.y >= 0f) ? this.m_WalkSpeed : this.m_BackwardWalkSpeed);
                this.m_CurrentMoveSpeed = MoveSpeed.Walk;
            }
            if (this.m_Player && this.m_Player.IsStaminaDepleted())
            {
                num = this.m_WalkSpeed;
                this.m_CurrentMoveSpeed = MoveSpeed.Walk;
                if (flag3)
                {
                    this.m_RunDepletedStamina = true;
                }
            }
        }
        if (this.m_Duck)
        {
            num *= this.m_DuckSpeedMul;
        }
        Vector3 vector2 = this.m_CharacterController.transform.InverseTransformVector(this.m_WantedSpeed.target);

        vector2.x = vector.x * num;
        vector2.z = vector.y * num;
        if (this.m_Dodge)
        {
            num = 10f;
            if (this.m_DodgeDirection != Direction.Backward)
            {
                vector2.x = ((this.m_DodgeDirection == Direction.Right) ? 1f : -1f);
                vector2.z = 0f;
            }
            else
            {
                vector2.x = 0f;
                vector2.z = -1f;
            }
            if (Time.time - this.m_DodgeStartTime > 0.15f)
            {
                this.m_Dodge = false;
            }
        }
        float y = vector2.y;

        vector2.y = 0f;
        vector2.Normalize();
        vector2  *= num;
        vector2.y = y;
        if (InventoryBackpack.Get().IsMaxOverload())
        {
            vector2 *= this.m_MaxOverloadSpeedMul;
        }
        bool flag5 = this.m_TimeInAir < 0.5f;

        if (flag5)
        {
            this.m_WantedSpeed.target = this.m_CharacterController.transform.TransformVector(vector2);
        }
        if (flag2)
        {
            this.m_SlideDir = this.m_AdditionalSpeed.normalized;
        }
        else if (!flag)
        {
            this.m_SlideDir = Vector3.zero;
        }
        if (flag || (!this.m_SlideDir.IsZero() && flag2))
        {
            Vector3 vector3 = this.m_WantedSpeed.target;
            vector3.y = 0f;
            Vector3 slideDir = this.m_SlideDir;
            slideDir.y = 0f;
            if (Vector3.Dot(vector3, slideDir) < 0f)
            {
                Vector3 normalized = Vector3.Cross(slideDir, Vector3.up).normalized;
                vector3 = Vector3.Dot(vector3, normalized) * normalized;
                this.m_WantedSpeed.target.x = vector3.x;
                this.m_WantedSpeed.target.z = vector3.z;
            }
        }
        if (Time.timeScale > 0f)
        {
            if (this.m_SlideDir.IsZero())
            {
                this.m_SlidingSpeedSoft.target = Vector3.zero;
                this.m_SlidingSpeedSoft.omega  = this.m_SlideDeceleration;
            }
            else
            {
                float proportionalClamp = CJTools.Math.GetProportionalClamp(0f, 1f, this.m_SlideAngle, this.m_CharacterController.slopeLimit, this.m_CharacterController.slopeLimit + 20f);
                this.m_SlidingSpeedSoft.target = this.m_SlideDir * this.m_SlideMaxSpeed * Mathf.Lerp(0.2f, 1f, proportionalClamp);
                this.m_SlidingSpeedSoft.omega  = Mathf.Lerp(this.m_SlideAcceleration * 0.1f, this.m_SlideAcceleration, proportionalClamp);
            }
            if (!flag5)
            {
                this.m_WantedSpeed.target = this.m_WantedSpeed.target - this.m_SlidingSpeedSoft;
            }
            this.m_SlidingSpeedSoft.Update(Time.deltaTime / Time.timeScale);
            this.m_WantedSpeed.target = this.m_WantedSpeed.target + this.m_SlidingSpeedSoft;
        }
        if (this.m_Player.m_UseGravity)
        {
            this.m_WantedSpeed.target = this.m_WantedSpeed.target + Physics.gravity * Time.deltaTime;
        }
        else
        {
            this.m_WantedSpeed.current.x = (this.m_WantedSpeed.target.x = 0f);
            this.m_WantedSpeed.current.y = (this.m_WantedSpeed.target.y = 0f);
            this.m_WantedSpeed.current.z = (this.m_WantedSpeed.target.z = 0f);
        }
        if (this.m_WantedSpeed.target.y < -10f)
        {
            this.m_WantedSpeed.target.y = -10f;
        }
        Vector3 b = Vector3.zero;

        if (!this.m_Player.GetMovesBlocked() && this.m_CharacterController.detectCollisions && !this.m_SkipCompensation && !FreeHandsLadderController.Get().IsActive())
        {
            b = -this.m_CharacterController.transform.TransformVector(this.m_Player.m_CharacterControllerDelta);
        }
        b.y = 0f;
        if ((this.m_CollisionFlags & CollisionFlags.Below) == CollisionFlags.None)
        {
            this.m_WantedSpeed.omega = this.m_AccelerationInAir;
            this.m_WantedPos.omega   = this.m_AccelerationInAir;
        }
        else if (this.m_Dodge)
        {
            this.m_WantedSpeed.omega = this.m_DodgeAcceleration;
            this.m_WantedPos.omega   = this.m_DodgeAcceleration;
        }
        else
        {
            this.m_WantedSpeed.omega = this.m_Acceleration;
            this.m_WantedPos.omega   = this.m_PositionAcceleration;
        }
        if (Time.timeScale > 0f)
        {
            this.m_WantedSpeed.Update(Time.deltaTime / Time.timeScale);
        }
        this.m_CurentMoveSpeed        = this.m_WantedSpeed.current.To2D().magnitude;
        this.m_CollisionFlagsAddSpeed = CollisionFlags.None;
        this.m_SlideAngle             = 0f;
        this.m_AdditionalSpeed        = Vector3.zero;
        this.m_CollisionFlags         = this.m_CharacterController.Move(this.m_Player.m_SpeedMul * this.m_WantedSpeed.current * Time.deltaTime, false);
        Vector2.zero.Set(this.m_WantedSpeed.current.x, this.m_WantedSpeed.current.z);
        if ((this.m_CollisionFlags & CollisionFlags.Sides) != CollisionFlags.None)
        {
            this.m_LastSideCollisionTime = Time.time;
        }
        if ((this.m_CollisionFlags & CollisionFlags.Below) != CollisionFlags.None && (this.m_LastCollisionFlags & CollisionFlags.Below) == CollisionFlags.None)
        {
            this.m_Player.OnLanding(this.m_CharacterController.velocity);
            this.m_JumpInProgress = false;
        }
        if ((this.m_CollisionFlags & CollisionFlags.Below) != CollisionFlags.None)
        {
            this.m_TimeInAir = 0f;
        }
        else
        {
            this.m_TimeInAir += Time.deltaTime;
        }
        this.m_LastCollisionFlags = this.m_CollisionFlags;
        this.m_SkipCompensation   = false;
        this.m_WantedPos.current  = base.transform.position;
        this.m_WantedPos.target   = this.m_CharacterController.transform.position + b;
        if (Time.timeScale > 0f)
        {
            this.m_WantedPos.Update(Time.deltaTime / Time.timeScale);
        }
        base.transform.position = this.m_WantedPos.current;
    }
示例#19
0
 void Start()
 {
     base.Start();
     bowScript = bow.GetComponent <BowController> ();
 }
示例#20
0
 void Start()
 {
     base.Start ();
     bowScript = bow.GetComponent<BowController> ();
 }
示例#21
0
    void Start()
    {
        ///Setting up the references
                if (target == null) {
                        target = GameObject.Find ("Target").GetComponent<Target> ();
                }

                if (bowControllerComponent == null) {
                        bowControllerComponent = GameObject.Find ("Bow").GetComponent<BowController> ();
                }

                Transform arrowClamPoints = bowControllerComponent.transform.Find ("ArrowClampPoints");

                if (rightClampPoint == null) {
                        rightClampPoint = arrowClamPoints.Find ("RightClampPoint");
                }

                if (leftClampPoint == null) {
                        leftClampPoint = arrowClamPoints.Find ("LeftClampPoint");
                }
    }