예제 #1
0
    /*private void Awake()
     * {
     *
     * }*/

    // Use this for initialization
    void Init()
    {
        mountInfo = PlayerInfoManager.Instance.PlayerInfo.mount;
        animal    = GetComponent <Animal>();
        mountable = GetComponent <Mountable>();
        UpdateMountInfo();
        isInit = true;
    }
예제 #2
0
        internal void SetDamageStuff(Vector3 OtherHitPoint, Transform other)
        {
            if (other.root == transform.root)
            {
                return;                               //if Im hitting myself
            }
            Mountable montura = other.GetComponentInParent <Mountable>();

            if (montura == Owner.Montura)
            {
                return;                           //if Im hitting my horse **New
            }
            if (!MalbersTools.Layer_in_LayerMask(other.gameObject.layer, HitMask))
            {
                return;                                                                   //Just hit what is on the HitMask Layer
            }
            DV = new DamageValues(meleeCollider.bounds.center - OtherHitPoint, Random.Range(MinDamage, MaxDamage));

            Debug.DrawLine(OtherHitPoint, meleeCollider.bounds.center, Color.red, 3f);


            if (canCauseDamage && !AlreadyHitted.Find(item => item == other.transform.root))                        //If can cause damage and If I didnt hit the same transform twice
            {
                AlreadyHitted.Add(other.transform.root);
                other.transform.root.SendMessage("getDamaged", DV, SendMessageOptions.DontRequireReceiver);         //To everybody who has GetDamaged()


                Rigidbody OtherRB = other.transform.root.GetComponent <Rigidbody>();

                if (OtherRB && other.gameObject.layer != 20)                                                        //Apply Force if the game object has a RigidBody && if is not an Animal
                {
                    OtherRB.AddExplosionForce(MinForce * 50, OtherHitPoint, 20);
                }

                PlaySound(3);                                                                                       //Play Hit Sound when get something

                OnHit.Invoke(other.gameObject);

                if (!meleeCollider.isTrigger)
                {
                    meleeCollider.enabled = false;
                }
            }
        }
예제 #3
0
 void Start()
 {
     animalMount = GetComponent <Mountable>();
     StartAgent();
 }