Ejemplo n.º 1
0
    void onCollision(Rigidbody body, EntityPlayer entity, Vector3 impactPoint)
    {
        if (m_state != GRENADE_STATE.TRAVELLING && m_state != GRENADE_STATE.BURNING)
        {
            return;
        }
        if (entity != null && (entity.m_team == GameData.TEAM.RED || entity.m_team == GameData.TEAM.BLUE))
        {
            onDirectHit(entity);
            m_state = GRENADE_STATE.DEAD;
            return;
        }
        if (body.gameObject.layer == PhysicsLayer.GET_LAYER(PHYSICS_LAYER.LAYER_RED_SHIELD) ||
            body.gameObject.layer == PhysicsLayer.GET_LAYER(PHYSICS_LAYER.LAYER_BLUE_SHIELD)
            )
        {
            m_state = GRENADE_STATE.DEAD;

            return;
        }
        if (m_state == GRENADE_STATE.TRAVELLING)
        {
            m_state = GRENADE_STATE.BURNING;
        }


        m_triggerEnter.enabled = false;
    }
Ejemplo n.º 2
0
        public override bool init(EntityPlayer entity)
        {
            base.init(entity);
            var obj = GameObject.Instantiate <Prefab>(PREFAB);

            obj.transform.position = this.transform.position;
            obj.transform.rotation = this.transform.rotation;
            if (isParented)
            {
                obj.transform.parent = this.transform;
            }
            if (isPhysicLayer)
            {
                obj.setLayer(PhysicsLayer.GET_LAYER(layer));
            }
            return(true);
        }
Ejemplo n.º 3
0
    //public NEntity.NScript.EntityScriptReader reader;


    //public NEntity.NScript.LoadNetworkPrefab loadRocketModel;
    //public NEntity.NScript.MoveForward move;
    //public NEntity.NScript.LoadNetworkPrefab loadExplosionModel;
    //public NEntity.NScript.LoadPrefab loadExplosionPlayer;
    //public NEntity.NScript.GameObjectDestroy destroyNetworkObject;

    public void init(
        NetworkPrefabLoader loader,
        GameData.TEAM team, EntityPlayer entity, Rigidbody krigidBody,
        Vector3 position, Vector3 to)
    {
        PhysicsLayer.SET_ATTACK(m_prefab, team);
        m_team          = team;
        m_networkloader = loader;
        m_networkloader.RpcLoadPrefab_ParentMe(PREFAB_ID.GRENADE, team);
        krigidBody.AddForce(entity.transform.rotation * m_initialForce, ForceMode.Impulse);
        //krigidBody.isKinematic = false;
        //m_explosion.gameObject.SetActive(false);
        m_entity    = entity;
        m_rigidbody = krigidBody;
        //Debug.Log(m_rigidbody);
        m_networkloader           = loader;
        m_triggerEnter.m_isRepeat = true;
        m_triggerEnter.resetCollisionCheck();
        m_triggerEnter.addHdr(onCollision);
        m_prefab.setLayer(PhysicsLayer.GET_LAYER(
                              (team == GameData.TEAM.RED) ? PHYSICS_LAYER.LAYER_RED_ATTACK : PHYSICS_LAYER.LAYER_BLUE_ATTACK));
    }