Ejemplo n.º 1
0
 public void SendMonAll()
 {
     if (dicDescriptor != null && dicDescriptor.Count != 0)
     {
         foreach (KeyValuePair <int, MonDesc> item in dicDescriptor)
         {
             MonDesc value = item.Value;
             if (value != null)
             {
                 GameObject gameObject = Get(value.Seq);
                 if (gameObject != null)
                 {
                     Transform  transform = gameObject.transform;
                     P2PManager instance  = P2PManager.Instance;
                     int        tblID     = value.tblID;
                     int        typeID    = value.typeID;
                     int        seq       = value.Seq;
                     Vector3    position  = transform.position;
                     float      x         = position.x;
                     Vector3    position2 = transform.position;
                     float      y         = position2.y;
                     Vector3    position3 = transform.position;
                     float      z         = position3.z;
                     Vector3    forward   = transform.forward;
                     float      x2        = forward.x;
                     Vector3    forward2  = transform.forward;
                     float      y2        = forward2.y;
                     Vector3    forward3  = transform.forward;
                     instance.SendPEER_MON_GEN(tblID, typeID, seq, x, y, z, x2, y2, forward3.z);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
    private Vector3 UpdateAI()
    {
        Vector3 vector = vCur;

        ApplyRigidity();
        float num = CalcRigidSpeed(moveSpeed);

        if (!bMoving)
        {
            if (!FindWay(vector))
            {
                FindWay(vector);
            }
            bMoving = true;
            if (!IsUpDown)
            {
                Vector3 forward = vTarget - vStart;
                forward.Normalize();
                base.transform.forward = forward;
            }
            if (readyP2P == 1 && MyInfoManager.Instance.Seq == RoomManager.Instance.Master)
            {
                readyP2P = 2;
                P2PManager instance = P2PManager.Instance;
                int        tblID    = monProp.Desc.tblID;
                int        typeID   = monProp.Desc.typeID;
                int        seq      = monProp.Desc.Seq;
                float      x        = vCur.x;
                float      y        = vCur.y;
                float      z        = vCur.z;
                Vector3    forward2 = base.transform.forward;
                float      x2       = forward2.x;
                Vector3    forward3 = base.transform.forward;
                float      y2       = forward3.y;
                Vector3    forward4 = base.transform.forward;
                instance.SendPEER_MON_GEN(tblID, typeID, seq, x, y, z, x2, y2, forward4.z);
            }
        }
        else
        {
            float num2 = Vector3.Distance(vTarget, vStart);
            deltaTime += Time.deltaTime;
            float num3 = deltaTime * (num / num2);
            if (num3 > 1f)
            {
                num3 = 1f;
            }
            vector = Vector3.Lerp(vStart, vTarget, num3);
            if (!IsUpDown)
            {
                Vector3 forward5 = vTarget - vStart;
                forward5.Normalize();
                base.transform.forward = forward5;
            }
            if (num3 >= 1f)
            {
                deltaTime = 0f;
                bMoving   = false;
                IsUpDown  = false;
                vStart    = vTarget;
                if (bLastTarget)
                {
                    rigidity = 0f;
                    bArrived = true;
                }
            }
        }
        return(vector);
    }
Ejemplo n.º 3
0
    public GameObject AddMon(MonDesc desc)
    {
        SpawnerDesc spawner = BrickManager.Instance.GetSpawner(Brick.SPAWNER_TYPE.DEFENCE_SPAWNER, 0);

        if (spawner == null)
        {
            return(null);
        }
        Vector3    position   = spawner.position;
        GameObject gameObject = null;

        if (desc.tblID == 0)
        {
            gameObject = (Object.Instantiate((Object)bee01, position, Quaternion.Euler(0f, 0f, 0f)) as GameObject);
        }
        else if (desc.tblID == 1)
        {
            gameObject = (Object.Instantiate((Object)bee02, position, Quaternion.Euler(0f, 0f, 0f)) as GameObject);
        }
        else if (desc.tblID == 2)
        {
            gameObject = (Object.Instantiate((Object)intruder01, position, Quaternion.Euler(0f, 0f, 0f)) as GameObject);
        }
        else if (desc.tblID == 3)
        {
            gameObject = (Object.Instantiate((Object)bomber01, position, Quaternion.Euler(0f, 0f, 0f)) as GameObject);
        }
        else if (desc.tblID == 4)
        {
            gameObject = (Object.Instantiate((Object)champ01, position, Quaternion.Euler(0f, 0f, 0f)) as GameObject);
        }
        if (null == gameObject)
        {
            Debug.LogError("Fail to instantiate a monster: " + desc.tblID);
            return(null);
        }
        MonProperty component = gameObject.GetComponent <MonProperty>();

        if (null == component)
        {
            Object.DestroyImmediate(gameObject);
            Debug.LogError("New monster doesnt have MonProperty: " + desc.tblID);
            return(null);
        }
        component.Desc           = desc;
        component.Desc.coreToDmg = DefenseManager.Instance.GetMonTable(desc.tblID).toCoreDmg;
        component.Desc.InitLog();
        component.InvisiblePosition = position;
        MonAI aIClass = Instance.GetAIClass(gameObject, desc.tblID);

        if (null == aIClass)
        {
            Object.DestroyImmediate(gameObject);
            Debug.LogError("New monster doesnt have monAI: " + desc.tblID);
            return(null);
        }
        aIClass.StartPosition = position;
        aIClass.moveSpeed     = DefenseManager.Instance.GetMonTable(desc.typeID).MoveSpeed;
        aIClass.MonType       = (MonAI.MON_TYPE)desc.typeID;
        dicMon.Add(desc.Seq, gameObject);
        aIClass.changeTexture();
        if (MyInfoManager.Instance.Seq == RoomManager.Instance.Master)
        {
            P2PManager instance = P2PManager.Instance;
            int        tblID    = desc.tblID;
            int        typeID   = desc.typeID;
            int        seq      = desc.Seq;
            float      x        = position.x;
            float      y        = position.y;
            float      z        = position.z;
            Vector3    forward  = gameObject.transform.forward;
            float      x2       = forward.x;
            Vector3    forward2 = gameObject.transform.forward;
            float      y2       = forward2.y;
            Vector3    forward3 = gameObject.transform.forward;
            instance.SendPEER_MON_GEN(tblID, typeID, seq, x, y, z, x2, y2, forward3.z);
        }
        return(gameObject);
    }