// Use this for initialization
 void Start()
 {
     rigid2d   = GetComponentInParent <Rigidbody2D>();
     npcclass  = GetComponentInParent <npcClass>();
     npcscript = GetComponentInParent <npcScript>();
     if (GameObject.FindGameObjectsWithTag("megumin_player").Length != 0)
     {
         selectEnemySystem = GameObject.FindGameObjectsWithTag("megumin_player")[0].GetComponent <selectEnemySystemScript>(); //
     }
     //npcSkeletonAnimation.state.Complete += State_End;
 }
 // Use this for initialization
 void Start()
 {
     rb2d                 = GetComponent <Rigidbody2D>();
     npcscript            = GetComponent <npcScript>();
     npcclass             = GetComponent <npcClass>();
     patrolLeftPointSave  = patrolLeftPoint.position;
     patrolRightPointSave = patrolRightPoint.position;
     if (transform.localScale.x < 0)
     {
         localScaleX = -1 * transform.localScale.x;
     }
     else
     {
         localScaleX = transform.localScale.x;
     }
 }
    // Use this for initialization
    void Awake()
    {
        if (transform.localScale.x < 0)
        {
            localScaleX = -1 * transform.localScale.x;
        }
        else
        {
            localScaleX = transform.localScale.x;
        }

        npcclass         = GetComponent <npcClass>();
        npcScript        = GetComponent <npcScript>();
        rb2d             = GetComponent <Rigidbody2D>();
        GroundCheckWall1 = npcScript.GroundCheckWall1;
        GroundCheckWall2 = npcScript.GroundCheckWall2;
    }
    // Use this for initialization
    void Start()
    {
        if (transform.localScale.x < 0)
        {
            localScaleX = -1 * transform.localScale.x;
        }
        else
        {
            localScaleX = transform.localScale.x;
        }


        SR               = GetComponent <SpriteRenderer>();
        npcclass         = GetComponent <npcClass>();
        npcScript        = GetComponent <npcScript>();
        GroundCheckWall1 = npcScript.GroundCheckWall1;
        GroundCheckWall2 = npcScript.GroundCheckWall2;
    }
Esempio n. 5
0
    // Use this for initialization
    void Awake()
    {
        rb2d                 = GetComponent <Rigidbody2D>();
        npcscript            = GetComponent <npcScript>();
        GroundCheckWall1     = npcscript.GroundCheckWall1;
        GroundCheckWall2     = npcscript.GroundCheckWall2;
        npcclass             = GetComponent <npcClass>();
        patrolLeftPointSave  = patrolLeftPoint.position;
        patrolRightPointSave = patrolRightPoint.position;
        if (transform.localScale.x < 0)
        {
            localScaleX = -1 * transform.localScale.x;
        }
        else
        {
            localScaleX = transform.localScale.x;
        }

        setPatrolDirection();
    }
Esempio n. 6
0
    /// <summary>
    /// 检测子弹的范围碰撞.
    /// </summary>
    void CheckAmmoOverlapSphereHit(Transform posTr = null)
    {
        bool    isDestroyAmmo = false;
        Vector3 pos           = posTr == null ? transform.position : posTr.position;

        Collider[] hits = Physics.OverlapSphere(pos, ShaShangDis, AmmoHitLayer);
        for (int i = 0; i < hits.Length; i++)
        {
            // Don't collide with triggers
            if (hits[i].isTrigger)
            {
                continue;
            }

            DaoJuCtrl daoJuCom = hits[i].GetComponent <DaoJuCtrl>();
            if (daoJuCom != null && daoJuCom.DaoJuState == DaoJuCtrl.DaoJuType.ZhangAiWu)
            {
                daoJuCom.OnDestroyThis();
                isDestroyAmmo = true;
            }

            NpcController npcCom = hits[i].GetComponent <NpcController>();
            if (npcCom != null)
            {
                npcCom.OnDaoDanHit(transform.position);
                isDestroyAmmo = true;
            }

            npcScript npcSp = hits[i].GetComponent <npcScript>();
            if (npcSp != null)
            {
                npcSp.OnDestroyThis();
                isDestroyAmmo = true;
            }
        }

        if (isDestroyAmmo)
        {
            OnDestroyThis();
        }
    }
Esempio n. 7
0
    void spawnOneHere()
    {
        //NPCObj = Instantiate(NPCPrefab, transform.position, Quaternion.identity) as GameObject;
        NPCObj = Instantiate(NPCPrefab, transform.position, transform.rotation) as GameObject;
        if (!NPCObj)
        {
            return;
        }
        SSMissionCleanup.GetInstance().AddObj(NPCObj);

        //find the NPC scritp and init the information of the NPC
        scriptObj = NPCObj.GetComponent <npcScript>();

        if (!scriptObj)
        {
            //Debug.Log(NPCObj.name + " has no npcScript");
            return;
        }

        scriptObj.initNPCInfor(pathNodeObj, speed, isLoop);
    }
Esempio n. 8
0
    /// <summary>
    /// 检测子弹的范围碰撞.
    /// </summary>
    void CheckAmmoOverlapSphereHit(Transform posTr = null)
    {
        bool    isDestroyAmmo = false;
        Vector3 pos           = posTr == null ? transform.position : posTr.position;

        Collider[] hits = Physics.OverlapSphere(pos, ShaShangDis, AmmoHitLayer);
        for (int i = 0; i < hits.Length; i++)
        {
            // Don't collide with triggers
            if (hits[i].isTrigger)
            {
                continue;
            }

            DaoJuCtrl daoJuCom = hits[i].GetComponent <DaoJuCtrl>();
            if (daoJuCom != null && daoJuCom.DaoJuState == DaoJuCtrl.DaoJuType.ZhangAiWu)
            {
                if (PlayerController.GetInstance() != null)
                {
                    PlayerController.GetInstance().NetSendAmmoHitZhangAiWuInfo(daoJuCom);
                }
                daoJuCom.OnDestroyThis();
                isDestroyAmmo = true;
            }

            NpcController npcCom = hits[i].GetComponent <NpcController>();
            if (npcCom != null)
            {
                npcCom.OnDaoDanHit(transform.position);
                isDestroyAmmo = true;
            }

            npcScript npcSp = hits[i].GetComponent <npcScript>();
            if (npcSp != null)
            {
                npcSp.OnDestroyThis();
                isDestroyAmmo = true;
                break;
            }

            PlayerController playerScript = hits[i].GetComponent <PlayerController>();
            if (playerScript != null && IsNetControlPort)
            {
                playerScript.OnAmmoHitPlayer();
            }
        }

        if (AmmoState == AmmoType.DiLei || AmmoState == AmmoType.TankPaoDan)
        {
            //地雷和坦克炮弹强制删除.
            isDestroyAmmo = true;
        }

        if (!IsNetControlPort)
        {
            //非主控制端时,由主控制端来删除网络子弹.
            isDestroyAmmo = false;
        }

        if (isDestroyAmmo)
        {
            OnDestroyThis();
        }
    }