A sphere-shaped primitive collider.

Inheritance: Collider
    // Use this for initialization
    void Awake()
    {
        // initialize variables
        //size = GetComponent<Renderer>().size;

        // initially false
        santaInSight = false;

        gameController = GetComponent<GameController>();
        anim = GetComponent<Animator>();
        nav = GetComponent<NavMeshAgent>();
        col = GetComponent<SphereCollider>();

        // Get reference to Santa
        santa = GameObject.FindWithTag("Player");

        // initially set vision to true
        checkVision = true;

        // Ignore layer 2. Layer 2 is default layer provided by unity which is Ignore Raycast
        layerMask = 1 << 2;
        layerMask = ~layerMask;

        // initialize ray position
        // slightly above ground level
        rayPos1 = new Vector3(0, 0.5f, 0);
    }
    //    private Item m_item;
    private void Start()
    {
        m_sphereCollider = this.GetComponent<SphereCollider>();
        m_renderer = this.GetComponent<Renderer>();

        //m_item = new Item(itemName, itemDesc, itemID, itemType);
    }
Exemple #3
0
 void Awake()
 {
     _radientOfsense = gameObject.GetComponent<SphereCollider> ();
     player = GameObject.FindWithTag ("Player");
     GirlSentence = false;
     //personaLastSighting =
 }
 protected override void Awake() {
     base.Awake();
     circleScaleFactor = 5F;
     (_collider as SphereCollider).radius = TempGameValues.UniverseCenterRadius;
     _keepoutCollider = gameObject.GetComponentsInChildren<SphereCollider>().Single(c => c.gameObject.layer == (int)Layers.CelestialObjectKeepout);
     _keepoutCollider.radius = (_collider as SphereCollider).radius * TempGameValues.KeepoutRadiusMultiplier;
 }
    //Vector3 eulerAngleVelocity;

    // Use this for initialization
    void Start()
    {

        rb = GetComponent<Rigidbody>();
        sph = GetComponent<SphereCollider>();

    }
Exemple #6
0
 void Awake()
 {
     detectionZone = GetComponent<SphereCollider>();
     rigidbody = GetComponent<Rigidbody>();
     playerStats = References.player.GetComponent<PlayerStats>();
     References.stateManager.changeState += onChangeState;
 }
Exemple #7
0
 // Use this for initialization
 void Awake()
 {
     _gameManager = GameObject.FindGameObjectWithTag(Tags.GameManager).GetComponent<GameManager>();
     sphereCol = GetComponent<SphereCollider>();
     animator = GetComponentInChildren<Animator>();
     audioSource = GetComponent<AudioSource>();
 }
Exemple #8
0
    // Use this for initialization
    void Awake()
    {
        if (StaticRef == null) // if theres is not allerdaye a static ref makes this the static ref
        {
            DontDestroyOnLoad(gameObject);
            StaticRef = this;
        }
        else if (StaticRef != this) // is the allready is a ref , destory this
        {
            Destroy(this);
        }

        player = GameController_script.playerRef;

        sphereRadius = this.GetComponent<SphereCollider>();

        hat = GameObject.FindGameObjectWithTag("hat").transform;

        book = GameObject.FindGameObjectWithTag("book").transform;

        book_anim = book.GetComponentInChildren<Animator>();

        hat.gameObject.SetActive(true);

        book.gameObject.SetActive(false);

        haveHat = HatState.Yes;

        hatSpwanTarget = GameObject.FindGameObjectWithTag("hatSpawn").transform;
    }
 void Start()
 {
     attackArea = transform.Find("AttackArea").GetComponent<SphereCollider>();
     pc = GetComponent<PlayerController>();
     animator = GetComponentInChildren<Animator>();
     attackableMask = 1 << LayerMask.NameToLayer("Attackable");
 }
    private void Awake()
    {
        StartCoroutine(Timer());

        coll = GetComponent<SphereCollider>();
        Destroy(this.gameObject,delay);
    }
 	void OnCollisionEnter(Collision collisionInfo)
	{
		//print("Detected collision between " + gameObject.name + " and " + collisionInfo.collider.name);
        //print("There are " + collisionInfo.contacts.Length + " point(s) of contacts");
        //print("Their relative velocity is " + collisionInfo.relativeVelocity);
      

        foreach (ContactPoint contact in collisionInfo.contacts)
        {
            //get the parent vehicle

          contact.thisCollider.GetComponent<Renderer>().material.color = Color.red;
           collider = GetComponent<SphereCollider>();
           if (collider != null)
            {

                collider =(SphereCollider)contact.thisCollider; //cast, we are only using spherecolliders
                float amount = collisionInfo.relativeVelocity.magnitude;
                print(contact.thisCollider + "-" + contact.thisCollider.GetInstanceID() + "-" + collider.radius + "-" + collider.center + "  " + amount);
              
                transform.root.gameObject.GetComponent<VehicleHealth>().InflictDamageby(amount); //damage health part
               // transform.FindChild("Body Parts").GetComponent<VehicleHealth>().InflictDamageby(amount);

            }
        }
	}
 /// <summary>
 ///   <para>Creates a ClothSphereColliderPair. If only one SphereCollider is given, the ClothSphereColliderPair will define a simple sphere. If two SphereColliders are given, the ClothSphereColliderPair defines a conic capsule shape, composed of the two spheres and the cone connecting the two.</para>
 /// </summary>
 /// <param name="a">The first SphereCollider of a ClothSphereColliderPair.</param>
 /// <param name="b">The second SphereCollider of a ClothSphereColliderPair.</param>
 public ClothSphereColliderPair(SphereCollider a)
 {
   this.m_First = (SphereCollider) null;
   this.m_Second = (SphereCollider) null;
   this.first = a;
   this.second = (SphereCollider) null;
 }
Exemple #13
0
 // Use this for initialization
 void Start()
 {
     anim = gameObject.GetComponent<Animation> ();
     sc = gameObject.GetComponent<SphereCollider> ();
     bc = gameObject.GetComponent<BoxCollider> ();
     initSound ();
 }
Exemple #14
0
    void Update()
    {
        if(gameObject.GetComponentInParent<weaponIndex>().ammoCount == 0 && !noAmmoBool && !doNotRunAgain){

            //Set weapon collider back to unarmed...
            col = GameObject.FindGameObjectWithTag ("Player").GetComponentInChildren<SphereCollider> ();
            col.enabled = false;
            noAmmoBool = true;
            nextAttack = Time.time + attackRate; //Prevents auto melee attack on ammo running out
            anim.SetTrigger(noAmmoHash);

            doNotRunAgain = true;
        }
        if (Input.GetButton ("Attack") && !Input.GetButton ("Shift") && Time.time > nextAttack && gameObject.GetComponentInParent<weaponIndex>().ammoCount == 0) {
            nextAttack = Time.time + attackRate;

            //Instantiate (meleeAudio, shotSpawn.position, shotSpawn.rotation);
            //Perform attack animation...
            anim.SetTrigger(meleeHash);

        }
        if(playSwing){
            Instantiate (meleeAudio, transform.position, transform.rotation);
        }
    }
Exemple #15
0
 // Use this for initialization
 void Start()
 {
     _explosionRange = this.GetComponent<SphereCollider>();
     _mesh = this.GetComponent<MeshRenderer>();
     _hasExploded = false;
     _explosionRange.enabled = false;
 }
Exemple #16
0
	// Use this for initialization
	void Start () {

        //instantiating the states
		idleState = new Idle (this);
		lostState = new Lost (this);
		distractedState = new Distracted (this);
		chasingState = new Chasing (this);
		alertedState = new Alerted (this);

		recoverState = new Recover (this);
		runState = new Run (this);
		scaredState = new Scared (this);
		tripState = new Trip (this);
		crouchState = new Crouch (this);

        //obtain components from the guard
        detection = GetComponent<SphereCollider>();
        agent = GetComponent<NavMeshAgent>();
        anim = GetComponent<Animator>();

        //stop rotation of guard when navigating
        agent.updateRotation = false;

        vision = transform.FindChild("Vision").gameObject; //obtain child object info
        startPos = transform.position; //obtain the start position of the guard

        //set first state as idle

        currentState = idleState;
        changeState(State._Idle);

    }
    private void Awake()
    {
        receiver = GetComponent<ControllerWheels>();
        sphereCollider = this.GetComponent<SphereCollider>();
        //Debug.LogWarning("HARDCODED");
        sphereCollider.isTrigger = true;
        sphereCollider.radius = 20f;

        receiverColliders = GetComponents<Collider>().ToList();
        receiverColliders = GetComponentsInChildren<Collider>().ToList();
        receiverColliders.ForEach(hC => Physics.IgnoreCollision(sphereCollider, hC));

        m_hRigidbody = this.GetComponent<Rigidbody>();

        //FSM
        idle = new StateIdle(this);
        patrol = new StatePatrol(this);
        onAir = new StateOnAir(this);
        wait = new StateWait(this);

        patrol.Idle = idle;
        patrol.OnAir = onAir;
        onAir.Wait = wait;
        wait.Patrol = patrol;

        currentState = idle;
        currentState.OnStateEnter();
    }
Exemple #18
0
 public override void Start()
 {
     this.theUnit.triggerTackle = this;
     this.triggering = theUnit;
     this.collider = this.GetComponent<SphereCollider>();
     base.Start();
 }
    private new void Awake()
    {
        base.Awake();

        m_animator = GetComponentInParent<Animator>();
        m_collider = GetComponent<SphereCollider>();
    }
 void Start()
 {
     Debug.Log("MagneticUpgrade Starting");
     _GameManager = GameManager.instance;
     _ScenePlayer = Player.instance;
     _coinRangeCollider = GetComponent<SphereCollider>(); ;
     if (_GameManager != null)
     {
         foreach (UpgradeStruct u in _GameManager._allUpgrades)
         {
             if (u.upgradeGOName == this.name)
             {
                 _UpgradeInfo = u;
                 u.upgradeScript = this;
                 Debug.Log("Upgrade Info Found");
             }
         }
     }
     foreach (UpgradeValue uv in _UpgradeInfo.upgradeValues)
     {
         if (uv.upgradeType == UpgradeType.CoinAttractRange)
         {
             _magnetRadius = uv.value;
             _coinRangeCollider.radius = uv.value;
         }
         else if (uv.upgradeType == UpgradeType.CoinAttractSpeed)
         {
             _magnetSpeed = uv.value;
         }
     }
 }
Exemple #21
0
 private void Awake()
 {
     triggerCollider = GetComponent<SphereCollider>();
     triggerCollider.enabled = Enabled;
     tracker = GetComponentInChildren<CollectibleTracker>();
     SceneManager.CollectibleCount++;
 }
	void Start () {
        body = GetComponent<Rigidbody>();
        forwardsVector = Vector3.forward;
        sphereCollider = GetComponent<SphereCollider>();

        input = PlayerInput.GetInput((int)playerNumber);
    }
 void Start()
 {
     MiMi = GameObject.FindGameObjectWithTag("MiMi");
     B4 = GameObject.FindGameObjectWithTag("B4");
     triggerZone = GetComponent<SphereCollider>();
     lightSource = GetComponent<Light>();
 }
 public ClothSphereColliderPair(SphereCollider a, SphereCollider b)
 {
     this.m_First = null;
     this.m_Second = null;
     this.first = a;
     this.second = b;
 }
 void OnDsiable()
 {
     print( "Awake Sphere spawn area" );
     spawnArea = GetComponent<SphereCollider>();
     spawnArea.isTrigger = true;
     base.OnDisable();
 }
    // Use this for initialization
    void Start()
    {
        collider = GetComponent<SphereCollider> ();
                exploded = false;

                if (shotType == 0) {
                        //Bomb
                        speed = 1f;
                        damage = 25f;
                        fullSize = 5f;
                        timer = Random.Range (5f, 25f);
                        shotScale = 1f;
                        gameObject.transform.localScale = new Vector3 (fullSize, fullSize, fullSize);
                        //Set appearance of Projectile
                }

                if (shotType == 1) {
                        //Bullet
                        speed = -.8f;
                        damage = 5f;
                        fullSize = 1f;
                        timer = 16f;
                        shotScale = 1f;
                        //Set appearance of Projectile
                }
    }
 public static float ComputeVolume(UnityEngine.Collider coll)
 {
     if (coll != null)
     {
         UnityEngine.CapsuleCollider collider = coll as UnityEngine.CapsuleCollider;
         if (collider != null)
         {
             UnityEngine.Vector3 lossyScale = collider.transform.lossyScale;
             float num  = collider.height * lossyScale.y;
             float num2 = collider.radius * UnityEngine.Mathf.Max(lossyScale.x, lossyScale.z);
             float num3 = (3.141593f * num2) * num2;
             float num4 = num3 * num;
             float num5 = (num3 * num2) * 1.333333f;
             return(num4 + num5);
         }
         UnityEngine.SphereCollider collider2 = coll as UnityEngine.SphereCollider;
         if (collider2 != null)
         {
             UnityEngine.Vector3 vector2 = collider2.transform.lossyScale;
             float[]             values  = new float[] { vector2.x, vector2.y, vector2.z };
             float num6 = collider2.radius * UnityEngine.Mathf.Max(values);
             return(4.18879f * ((num6 * num6) * num6));
         }
         UnityEngine.BoxCollider collider3 = coll as UnityEngine.BoxCollider;
         if (collider3 != null)
         {
             UnityEngine.Vector3 vector3 = collider3.transform.lossyScale;
             UnityEngine.Vector3 size    = collider3.size;
             return(((size.x * vector3.x) * (size.y * vector3.y)) * (size.z * vector3.z));
         }
         UnityEngine.Debug.LogWarning("Not implemented for " + coll.GetType() + " type!");
     }
     return(0f);
 }
Exemple #28
0
 public void Start()
 {
     plsh = GetComponent<playerShooting>();
     rb = GetComponent<Rigidbody>();
     col = GetComponent<SphereCollider>();
     calculator = GameObject.FindGameObjectWithTag("scripts").GetComponent<Calculator>();
     sightConstant = calculator.getSightConstant();
     fieldofViewAngle = calculator.getFieldOfView();
     sensitivity = calculator.getSensitivity();
     rotateToTargetSpeed = calculator.getRotateSpeed();
     index = calculator.addBot(this);
     targets = calculator.getTargets(index);
     col.radius= (float)sightConstant;
     shootFlag = false;
     playerInSight = false;
     moveBool = new bool[calculator.getMasterBoolLength()];
     bestPoint = transform.position;
     bestPoints = new Vector3[moveBool.Length];
     bestPointsSV = new float[moveBool.Length];
     team = GetComponent<TeamMember>().teamID;
     teamFinder();
     if (team == 1)
     {
         goal = new Vector3(-37f, -30f, 28f);
     }
     else if(team == 2)
     {
         goal = new Vector3(64f, -30f, -43f);
     }
 }
 static public int constructor(IntPtr l)
 {
     UnityEngine.SphereCollider o;
     o = new UnityEngine.SphereCollider();
     pushObject(l, o);
     return(1);
 }
Exemple #30
0
 void Start()
 {
     audio = GetComponent<AudioSource>();
     player = PlayerHealth.instance;
     collider = GetComponentInChildren<SphereCollider>();
     anim = GetComponentInChildren<Animator>();
 }
 void Start()
 {
     print( "Start Sphere spawn area" );
     spawnArea = GetComponent<SphereCollider>();
     spawnArea.isTrigger = true;
     base.Start();
 }
Exemple #32
0
    void Awake()
    {
        unit = GetComponent<Unit>();
        sphereCol = GetComponent<SphereCollider>();

        attackTimer = unit.attackInterval;
    }
 static public int set_center(IntPtr l)
 {
     UnityEngine.SphereCollider o = (UnityEngine.SphereCollider)checkSelf(l);
     UnityEngine.Vector3        v;
     checkType(l, 2, out v);
     o.center = v;
     return(0);
 }
    static public int set_radius(IntPtr l)
    {
        UnityEngine.SphereCollider o = (UnityEngine.SphereCollider)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.radius = v;
        return(0);
    }
 static public int get_radius(IntPtr l)
 {
     try {
         UnityEngine.SphereCollider self = (UnityEngine.SphereCollider)checkSelf(l);
         pushValue(l, self.radius);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #36
0
 static public int get_center(IntPtr l)
 {
     try {
         UnityEngine.SphereCollider self = (UnityEngine.SphereCollider)checkSelf(l);
         pushValue(l, self.center);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int get_center(IntPtr l)
 {
     try {
         UnityEngine.SphereCollider self = (UnityEngine.SphereCollider)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.center);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.SphereCollider o;
         o = new UnityEngine.SphereCollider();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_radius(IntPtr l)
 {
     try {
         UnityEngine.SphereCollider self = (UnityEngine.SphereCollider)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.radius = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #40
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.SphereCollider o;
         o = new UnityEngine.SphereCollider();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemple #41
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.SphereCollider o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.SphereCollider();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
 static public int set_center(IntPtr l)
 {
     try {
         UnityEngine.SphereCollider self = (UnityEngine.SphereCollider)checkSelf(l);
         UnityEngine.Vector3        v;
         checkType(l, 2, out v);
         self.center = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #43
0
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.SphereCollider sphereCollider = (UnityEngine.SphereCollider)value;
     writer.WriteProperty("center", sphereCollider.center);
     writer.WriteProperty("radius", sphereCollider.radius);
     writer.WriteProperty("enabled", sphereCollider.enabled);
     writer.WriteProperty("isTrigger", sphereCollider.isTrigger);
     writer.WriteProperty("contactOffset", sphereCollider.contactOffset);
     writer.WriteProperty("material", sphereCollider.material);
     writer.WriteProperty("sharedMaterial", sphereCollider.sharedMaterial);
     writer.WriteProperty("tag", sphereCollider.tag);
     writer.WriteProperty("name", sphereCollider.name);
     writer.WriteProperty("hideFlags", sphereCollider.hideFlags);
 }
// fields

// properties
    static void SphereCollider_center(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.SphereCollider _this = (UnityEngine.SphereCollider)vc.csObj;
            var result = _this.center;
            JSApi.setVector3S((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.Vector3        arg0  = (UnityEngine.Vector3)JSApi.getVector3S((int)JSApi.GetType.Arg);
            UnityEngine.SphereCollider _this = (UnityEngine.SphereCollider)vc.csObj;
            _this.center = arg0;
        }
    }
 static void SphereCollider_radius(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.SphereCollider _this = (UnityEngine.SphereCollider)vc.csObj;
         var result = _this.radius;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.SphereCollider _this = (UnityEngine.SphereCollider)vc.csObj;
         _this.radius = arg0;
     }
 }
 static void ClothSphereColliderPair_second(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.ClothSphereColliderPair _this = (UnityEngine.ClothSphereColliderPair)vc.csObj;
         var result = _this.second;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.SphereCollider          arg0  = (UnityEngine.SphereCollider)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.ClothSphereColliderPair _this = (UnityEngine.ClothSphereColliderPair)vc.csObj;
         _this.second = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
Exemple #47
0
    static int _CreateUnityEngine_SphereCollider(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 0)
        {
            UnityEngine.SphereCollider obj = new UnityEngine.SphereCollider();
            ToLua.Push(L, obj);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: UnityEngine.SphereCollider.New");
        }

        return(0);
    }
    static int get_radius(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.SphereCollider obj = (UnityEngine.SphereCollider)o;
            float ret = obj.radius;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index radius on a nil value"));
        }
    }
Exemple #49
0
    static int set_center(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.SphereCollider obj  = (UnityEngine.SphereCollider)o;
            UnityEngine.Vector3        arg0 = ToLua.ToVector3(L, 2);
            obj.center = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index center on a nil value"));
        }
    }
Exemple #50
0
    static int set_radius(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.SphereCollider obj = (UnityEngine.SphereCollider)o;
            float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
            obj.radius = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index radius on a nil value"));
        }
    }
Exemple #51
0
    static int get_center(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.SphereCollider obj = (UnityEngine.SphereCollider)o;
            UnityEngine.Vector3        ret = obj.center;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index center on a nil value"));
        }
    }
    static int get_radius(IntPtr L)
    {
        UnityEngine.SphereCollider obj = (UnityEngine.SphereCollider)ToLua.ToObject(L, 1);
        float ret;

        try
        {
            ret = obj.radius;
        }
        catch (Exception e)
        {
            return(LuaDLL.luaL_error(L, obj == null ? "attempt to index radius on a nil value" : e.Message));
        }

        LuaDLL.lua_pushnumber(L, ret);
        return(1);
    }
    static bool ClothSphereColliderPair_ClothSphereColliderPair2(JSVCall vc, int argc)
    {
        int _this = JSApi.getObject((int)JSApi.GetType.Arg);

        JSApi.attachFinalizerObject(_this);
        --argc;

        int len = argc;

        if (len == 1)
        {
            UnityEngine.SphereCollider arg0 = (UnityEngine.SphereCollider)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSMgr.addJSCSRel(_this, new UnityEngine.ClothSphereColliderPair(arg0));
        }

        return(true);
    }
    static int get_center(IntPtr L)
    {
        UnityEngine.SphereCollider obj = (UnityEngine.SphereCollider)ToLua.ToObject(L, 1);
        UnityEngine.Vector3        ret;

        try
        {
            ret = obj.center;
        }
        catch (Exception e)
        {
            return(LuaDLL.luaL_error(L, obj == null ? "attempt to index center on a nil value" : e.Message));
        }

        ToLua.Push(L, ret);
        return(1);
    }
Exemple #55
0
    private void createEveryDetectors()
    {
        this.dummy       = new GO();
        this.dummy.layer = this.gameObject.layer;
        RB rb = this.dummy.AddComponent <RB>();

        rb.useGravity  = false;
        rb.isKinematic = true;
        SC sc = this.dummy.AddComponent <SC>();

        sc.radius    = 0.125f;
        sc.isTrigger = true;
        this.dummy.AddComponent <RelCol>();

        this.forEachPos((x) => this.createDetector(x));

        Obj.DestroyImmediate(this.dummy);
    }
Exemple #56
0
    static int get_center(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.SphereCollider.center");
#endif
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.SphereCollider obj = (UnityEngine.SphereCollider)o;
            UnityEngine.Vector3        ret = obj.center;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index center on a nil value"));
        }
    }
Exemple #57
0
    static int get_radius(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.SphereCollider.radius");
#endif
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.SphereCollider obj = (UnityEngine.SphereCollider)o;
            float ret = obj.radius;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index radius on a nil value"));
        }
    }
Exemple #58
0
    void Start()
    {
        GO tracker = new GO();

        tracker.layer = this.gameObject.layer;
        RB rb = tracker.AddComponent <RB>();

        rb.useGravity  = false;
        rb.isKinematic = true;
        SC sc = tracker.AddComponent <SC>();

        sc.radius    = 0.125f;
        sc.isTrigger = true;
        tracker.AddComponent <RelCol>();

        /* Generate as many detectors as requested */
        Tr t = this.transform;

        for (int i = 1; i <= this.MaxDepth; i++)
        {
            /* XXX: (again) This was the only way I found to instantiate
             * the clone in local space... */
            GO obj = Obj.Instantiate(tracker, t.position, Quat.identity, t);
            obj.name = $"ShadowTracker_{i}";
            Vec3 pos = new Vec3(0.0f, i * -1.0f, 0.0f);
            obj.transform.Translate(pos, UnityEngine.Space.World);
        }

        Obj.DestroyImmediate(tracker);

        for (int i = 0; i < this.MaxDepth * 2; i++)
        {
            List node = new List();
            node.next      = this.emptyList;
            this.emptyList = node;
        }

        this.touchingList = null;
        this.self         = this.transform;
    }
    static string exportCollider(GameObject resource)
    {
        UnityEngine.Collider       c  = resource.GetComponent <UnityEngine.Collider>();
        UnityEngine.SphereCollider sc = resource.GetComponent <UnityEngine.SphereCollider>();

        if (sc != null)
        {
            return(String.Format(
                       "public override Collider Collider {{ get {{ return new SphereCollider(Vector3.Zero, new Vector3({0}f, {1}f, {2}f), {3}f); }} }}",
                       c.bounds.center.x, c.bounds.center.y, c.bounds.center.z, sc.radius
                       ));
        }
        else if (c != null)
        {
            return(String.Format(
                       "public override Collider Collider {{ get {{ return new BoxCollider(Vector3.Zero, new Vector3({0}f, {1}f, {2}f), new Vector3({3}f, {4}f, {5}f)); }} }}",
                       c.bounds.extents.x, c.bounds.extents.y, c.bounds.extents.z, c.bounds.center.x, c.bounds.center.y, c.bounds.center.z
                       ));
        }

        return("");
    }
Exemple #60
0
    static int _CreateUnityEngine_SphereCollider(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                UnityEngine.SphereCollider obj = new UnityEngine.SphereCollider();
                ToLua.PushSealed(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.SphereCollider.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }