Exemplo n.º 1
0
    public static void OnMonsterAdd(int id, AiNetwork ai, Pathea.PeEntity entity)
    {
        EntityMonsterBeacon mbEntity = Pathea.EntityMgr.Instance.Get(id) as EntityMonsterBeacon;

        if (null != mbEntity)
        {
            mbEntity.OnMonsterCreated(entity);
        }
        else
        {
            if (null != entity)
            {
                Pathea.CommonCmpt cc = entity.GetCmpt <Pathea.CommonCmpt>();
                if (cc != null)
                {
                    AiTowerDefense td = AiTowerDefense.Get <AiTowerDefense>(id);
                    if (null != td)
                    {
                        cc.TDpos = td._pos;
                    }
                }

                Pathea.SkAliveEntity sae = entity.GetCmpt <Pathea.SkAliveEntity>();
                if (sae != null)
                {
                    sae.SetAttribute(Pathea.AttribType.DefaultPlayerID, 8);
                    sae.SetAttribute(Pathea.AttribType.CampID, 26);
                }
            }
        }
    }
    public static IEnumerator RequestTowerDefense(int missionId, int targetId)
    {
        while (null == mainPlayer)
        {
            yield return(null);
        }

        Vector3 mPos = AiTowerDefense.GetTdGenPos(targetId);

        mainPlayer.RPCServer(EPacketType.PT_InGame_MissionTowerDefense, missionId, targetId, mPos);
    }
Exemplo n.º 3
0
    protected override void OnPEDestroy()
    {
        base.OnPEDestroy();
        mInstance = null;
        Pathea.PeCreature.Instance.Destory(Id);
        if (null != m_Mark)
        {
            PeMap.LabelMgr.Instance.Remove(m_Mark);
        }

        if (null != UITowerInfo.Instance)
        {
            UITowerInfo.Instance.isShow = false;
        }
    }
Exemplo n.º 4
0
 protected override void OnPEAwake()
 {
     base.OnPEAwake();
     mInstance = this;
 }
Exemplo n.º 5
0
    //	public override void OnPeMsg(EMsg msg, params object[] args)
    //	{
    //		switch (msg)
    //		{
    //			case EMsg.Lod_Collider_Destroying:
    //				canGetAuth = false;
    //				lastAuthId = authId;

    //				if (hasOwnerAuth)
    //				{
    //#if UNITY_EDITOR
    //					Debug.LogFormat("<color=blue>you lost [{0}]'s authority.</color>", Id);
    //#endif

    //					authId = -1;
    //					RPCServer(EPacketType.PT_InGame_LostController);
    //				}
    //				ResetContorller();
    //				break;

    //			case EMsg.Lod_Collider_Created:
    //				canGetAuth = true;
    //				if (!hasAuth)
    //				{
    //					RPCServer(EPacketType.PT_InGame_SetController);
    //				}
    //				else
    //				{
    //					ResetContorller();

    //#if UNITY_EDITOR
    //					PlayerNetwork p = PlayerNetwork.GetPlayer(authId);
    //					if (null != p)
    //						Debug.LogFormat("<color=blue>{0} got [{1}]'s authority.</color>", p.RoleName, Id);
    //#endif
    //				}
    //				break;
    //		}
    //	}

    internal void CreateAi()
    {
        _entity = PeEntityCreator.Instance.CreateMonsterNet(Id, ExternId, Vector3.zero, Quaternion.identity, Vector3.one, Scale, _buffId);
        if (null == _entity)
        {
            return;
        }

        if (_fixId != -1)
        {
            SceneEntityCreatorArchiver.Instance.SetEntityByFixedSpId(_fixId, _entity);
            // if (_entity.monster) _entity.monster.Ride(false);
        }

        _entity.monster.Ride(_canride);

        _viewTrans = _entity.GetCmpt <PeTrans>();
        if (null == _viewTrans)
        {
            Debug.LogError("entity has no ViewCmpt");
            return;
        }

        _viewTrans.position = transform.position;

        _move = _entity.GetCmpt <Motion_Move>();

        NetCmpt net = _entity.GetCmpt <NetCmpt>();

        if (null == net)
        {
            net = _entity.Add <NetCmpt>();
        }

        net.network = this;

        MonsterProtoDb.Item data = MonsterProtoDb.Get(ExternId);
        if (null == data)
        {
            gameObject.name = string.Format("TemplateId:{0}, Id:{1}", ExternId, Id);
        }
        else
        {
            gameObject.name = string.Format("{0}, TemplateId:{1}, Id:{2}", data.name, ExternId, Id);
        }

        if (-1 != _groupId)
        {
            AIGroupNetWork.OnMonsterAdd(_groupId, this, _entity);
        }

        if (-1 != _tdId)
        {
            AiTowerDefense.OnMonsterAdd(_tdId, this, _entity);
            if (_entity.monster)
            {
                _entity.monster.Ride(false);
            }
        }

        if (-1 != _dungeonId)
        {
            _entity.SetAttribute(AttribType.CampID, DungeonMonster.CAMP_ID);
            _entity.SetAttribute(AttribType.DamageID, DungeonMonster.DAMAGE_ID);

            if (_entity.monster)
            {
                _entity.monster.Ride(false);
            }
        }

        if (-1 != _colorType)
        {
            PeEntityCreator.InitMonsterSkinRandomNet(_entity, _colorType);
        }

        if (-1 != _playerId)
        {
            _entity.SetAttribute(AttribType.DefaultPlayerID, _playerId);
        }

        OnSpawned(_entity.GetGameObject());
        if (_entity.Race == ERace.Mankind && _entity.proto == EEntityProto.Monster)
        {
            _move.AddNetTransInfo(transform.position, rot.eulerAngles, _move.speed, GameTime.Timer.Second);
        }
        else
        {
            _move.NetMoveTo(transform.position, Vector3.zero);
        }
        //     if (_move is Motion_Move_Motor)
        //(_move as Motion_Move_Motor).NetMoveTo( transform.position,Vector3.zero);
    }