Ejemplo n.º 1
0
        // 通知服务器控制相应AI  C#  ---->  C++
        public void OnAICommandBtnClick(int nSlotId)
        {
            if (IsOutOfMyTeamArray(nSlotId))
            {
                return;
            }

            if (!LogicDataCenter.teamRightWndDataManager.MyTeamEntityIdTable.ContainsKey(nSlotId))
            {
                return;
            }
            int nUID = (int)LogicDataCenter.teamRightWndDataManager.MyTeamEntityIdTable[nSlotId];

            if (LogicDataCenter.teamRightWndDataManager.BIsJoinFollow[nSlotId])
            {
                // 图片变为加入跟随
                AICommandBtn[nSlotId].GetComponent <Image>().sprite = AIBtnIcon[0];

                cmd_war_ai_command_break_follow data = new cmd_war_ai_command_break_follow();
                data.uidTarget = nUID;
                EntityEventHelper.Instance.SendCommand <cmd_war_ai_command_break_follow>(EntityFactory.MainHeroID, EntityLogicDef.ENTITY_CMD_AI_COMMAND_BREAK_FOLLOW, ref data);
            }
            else
            {
                // 图片变为取消跟随
                AICommandBtn[nSlotId].GetComponent <Image>().sprite = AIBtnIcon[1];

                cmd_war_ai_command_follow data = new cmd_war_ai_command_follow();
                data.uidTarget = nUID;
                EntityEventHelper.Instance.SendCommand <cmd_war_ai_command_follow>(EntityFactory.MainHeroID, EntityLogicDef.ENTITY_CMD_AI_COMMAND_FOLLOW, ref data);
            }

            LogicDataCenter.teamRightWndDataManager.BIsJoinFollow[nSlotId] = !LogicDataCenter.teamRightWndDataManager.BIsJoinFollow[nSlotId];
        }
Ejemplo n.º 2
0
    private void OnAICommand()
    {
        int targetID = 0;

        if (raycast.targetID > 0)
        {
            EntityView evTarget       = EntityFactory.getEntityViewByID(raycast.targetID);
            EntityView evMainHeroView = EntityFactory.MainHeroView;
            if (evTarget != null && evTarget.IsValid)
            {
                if (evTarget.CampFlag == CampFlag.CampFlag_Friend && evTarget.Type == ENTITY_TYPE.TYPE_PLAYER_ROLE)
                {
                    // 1.发送服务器要(1)控制或(2)解除或   暂时没有该功能//(3)移交targetID的友方英雄单位
                    if (evTarget.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_AI_SCHEME_ID) > 0)
                    {
                        targetID = raycast.targetID;
                        if (!LogicDataCenter.teamRightWndDataManager.MyTeamUIDTable.ContainsKey(targetID))
                        {
                            return;
                        }
                        TeamRightInfo teamRightInfo = LogicDataCenter.teamRightWndDataManager.MyTeamUIDTable[targetID] as TeamRightInfo;

                        int       groundLightEffectID     = 0;
                        const int helpmeSignLightEffectID = 13;
                        const int dangerSignLightEffectID = 12;
                        if (LogicDataCenter.teamRightWndDataManager.BIsJoinFollow[teamRightInfo.nSlotId])
                        {
                            cmd_war_ai_command_break_follow data = new cmd_war_ai_command_break_follow();
                            data.uidTarget = targetID;
                            EntityEventHelper.Instance.SendCommand <cmd_war_ai_command_break_follow>(EntityFactory.MainHeroID, EntityLogicDef.ENTITY_CMD_AI_COMMAND_BREAK_FOLLOW, ref data);

                            groundLightEffectID = dangerSignLightEffectID;
                        }
                        else
                        {
                            cmd_war_ai_command_follow data = new cmd_war_ai_command_follow();
                            data.uidTarget = targetID;
                            EntityEventHelper.Instance.SendCommand <cmd_war_ai_command_follow>(EntityFactory.MainHeroID, EntityLogicDef.ENTITY_CMD_AI_COMMAND_FOLLOW, ref data);

                            groundLightEffectID = helpmeSignLightEffectID;
                        }
                        LogicDataCenter.teamRightWndDataManager.BIsJoinFollow[teamRightInfo.nSlotId] = !LogicDataCenter.teamRightWndDataManager.BIsJoinFollow[teamRightInfo.nSlotId];

                        // 添加地面光效
                        Vector3 pos = new Vector3();
                        if (MouseRaycastToGround(ref pos))
                        {
                            int        LayerMaskOnPos   = (1 << LayerMask.NameToLayer(Config.LayerDefault) | 1 << LayerMask.NameToLayer(Config.LayerBuilding));
                            Ray        PointToGroundRay = new Ray(pos + new Vector3(0, 0.5f, 0), new Vector3(0, -1, 0));
                            RaycastHit projectInfo;
                            Physics.Raycast(PointToGroundRay, out projectInfo, 100, LayerMaskOnPos);
                            pos = projectInfo.point;

                            LightEffectParam param = new LightEffectParam();
                            param.nSrcEntityID = evMainHeroView.ID;
                            param.sourcePos    = pos;
                            param.targetPos    = pos;
                            LightingEffectManager lem = evMainHeroView.LightingEffectManager;
                            if (lem != null && lem)
                            {
                                lem.AddLighting(groundLightEffectID, param);
                            }
                        }
                    }
                }
            }
        }
    }