當前位置: 首頁>>代碼示例>>C#>>正文


C# MyEntityDetector.Init方法代碼示例

本文整理匯總了C#中MinerWars.AppCode.Game.Entities.EntityDetector.MyEntityDetector.Init方法的典型用法代碼示例。如果您正苦於以下問題:C# MyEntityDetector.Init方法的具體用法?C# MyEntityDetector.Init怎麽用?C# MyEntityDetector.Init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MinerWars.AppCode.Game.Entities.EntityDetector.MyEntityDetector的用法示例。


在下文中一共展示了MyEntityDetector.Init方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: InitShipDetector

        private void InitShipDetector()
        {
            //MyDetectingCriteria detectingCriteria = new MyDetectingCriteria();

            //detectingCriteria.DetectingCriteria.Add(
            //new MyDetectingCriterium(
            //    MyDetectedEntityAction.TradeForFree,
            //    new MyDetectingCondition<MyEntity>(
            //    //x => (MyFactions.GetFactionsRelation(this.Faction, x.Faction) == MyFactionRelationEnum.Friend) && (x is MySmallShip || x is MyPrefabHangar || x is MyFoundationFactory) && ((IMyInventory)x).Inventory != null,
            //        x => (MyFactions.GetFactionsRelation(this.Faction, x.Faction) == MyFactionRelationEnum.Friend) && (x is MySmallShip || x is MyPrefabHangar) && ((IMyInventory)x).Inventory != null,
            //        MySmallShipConstants.DETECT_SHIP_RADIUS)));
            //detectingCriteria.DetectingCriteria.Add(
            //    new MyDetectingCriterium(
            //        MyDetectedEntityAction.TradeForMoney,
            //        new MyDetectingCondition<MyEntity>(
            //            x => (MyFactions.GetFactionsRelation(this.Faction, x.Faction) == MyFactionRelationEnum.Neutral) && (x is MySmallShip || x is MyPrefabHangar) && !x.IsCripple() && ((IMyInventory)x).Inventory != null,
            //            MySmallShipConstants.DETECT_SHIP_RADIUS)));
            //detectingCriteria.DetectingCriteria.Add(
            //    new MyDetectingCriterium(
            //        MyDetectedEntityAction.Steal,
            //        new MyDetectingCondition<MyEntity>(
            //            x => (MyFactions.GetFactionsRelation(this.Faction, x.Faction) == MyFactionRelationEnum.Enemy || MyFactions.GetFactionsRelation(this.Faction, x.Faction) == MyFactionRelationEnum.Neutral) && x.IsCripple() && x is MySmallShip,
            //            MySmallShipConstants.DETECT_SHIP_RADIUS)));
            //detectingCriteria.DetectingCriteria.Add(
            //    new MyDetectingCriterium(
            //        MyDetectedEntityAction.Build,
            //    //new MyDetectingCondition<MyFoundationFactory>(
            //    //    x => true,
            //        new MyDetectingCondition<MyPrefabContainer>(
            //            x => (MyFactions.GetFactionsRelation(this.Faction, x.Faction) == MyFactionRelationEnum.Friend) && x.ContainsPrefab(PrefabTypesFlagEnum.FoundationFactory),
            //            MySmallShipConstants.DETECT_FOUNDATION_FACTORY_RADIUS)));

            //ShipDetector = new MyShipDetector(this, detectingCriteria);

            List<IMyEntityDetectorCriterium> tradeCriterias = new List<IMyEntityDetectorCriterium>()
                {
                    new MyEntityDetectorCriterium<MyEntity>((int)MySmallShipInteractionActionEnum.TradeForFree, 
                        MySmallShipInteraction.CanTradeForFree, true, this),                    
                    new MyEntityDetectorCriterium<MyEntity>((int)MySmallShipInteractionActionEnum.TradeForMoney, 
                        MySmallShipInteraction.CanTrade, true, this),
                    new MyEntityDetectorCriterium<MySmallShip>((int)MySmallShipInteractionActionEnum.Loot, 
                        MySmallShipInteraction.CanLootShip, true, this),
                    new MyEntityDetectorCriterium<MyCargoBox>((int)MySmallShipInteractionActionEnum.Examine,
                        MySmallShipInteraction.CanExamineCargoBox, true, this),
                    new MyEntityDetectorCriterium<MyCargoBox>((int)MySmallShipInteractionActionEnum.ExamineEmpty,
                        MySmallShipInteraction.CanExamineEmptyCargoBox, true, this),
                    new MyEntityDetectorCriterium<MyEntity>((int)MySmallShipInteractionActionEnum.Blocked, 
                        MySmallShipInteraction.IsBlocked, true, this),
                };
            List<IMyEntityDetectorCriterium> buildCriterias = new List<IMyEntityDetectorCriterium>()
                {
                    new MyEntityDetectorCriterium<MyPrefabContainer>((int) MySmallShipInteractionActionEnum.Build,
                        MySmallShipInteraction.CanBuild, this)
                };
            List<IMyEntityDetectorCriterium> motherShipCriterias = new List<IMyEntityDetectorCriterium>()
                {
                    new MyEntityDetectorCriterium<MyPrefabHangar>(1, MySmallShipInteraction.IsNearMothership, true, this)
                };
            List<IMyEntityDetectorCriterium> useableEntityCriterias = new List<IMyEntityDetectorCriterium>()
                {
                    new MyEntityDetectorCriterium<MyEntity>((int)MySmallShipInteractionActionEnum.Use, 
                        MySmallShipInteraction.CanUse, true, this),
                    new MyEntityDetectorCriterium<MyEntity>((int)MySmallShipInteractionActionEnum.Hack, 
                        MySmallShipInteraction.CanHack, true, this),
                };

            TradeDetector = new MyEntityDetector();
            TradeDetector.Init(null, new MyMwcObjectBuilder_EntityDetector(new Vector3(MySmallShipConstants.DETECT_SHIP_RADIUS * 2f, 0f, 0f), MyMwcObjectBuilder_EntityDetector_TypesEnum.Sphere), this, WorldMatrix, tradeCriterias);
            TradeDetector.OnNearestEntityChange += OnNearestDetectedEntityChanged;
            TradeDetector.OnNearestEntityCriteriasChange += OnNearestDetectedEntityCriteriasChanged;

            BuildDetector = new MyEntityDetector();
            BuildDetector.Init(null, new MyMwcObjectBuilder_EntityDetector(new Vector3(MySmallShipConstants.DETECT_FOUNDATION_FACTORY_RADIUS * 2f, 0f, 0f), MyMwcObjectBuilder_EntityDetector_TypesEnum.Sphere), this, WorldMatrix, buildCriterias);
            BuildDetector.OnNearestEntityChange += OnNearestDetectedEntityChanged;
            BuildDetector.OnNearestEntityCriteriasChange += OnNearestDetectedEntityCriteriasChanged;

            MotherShipDetector = new MyEntityDetector();
            MotherShipDetector.Init(null, new MyMwcObjectBuilder_EntityDetector(new Vector3(MySmallShipConstants.DETECT_SHIP_RADIUS * 2f, 0f, 0f), MyMwcObjectBuilder_EntityDetector_TypesEnum.Sphere), this, WorldMatrix, motherShipCriterias);
            MotherShipDetector.OnNearestEntityChange += OnNearestDetectedEntityChanged;
            MotherShipDetector.OnNearestEntityCriteriasChange += OnNearestDetectedEntityCriteriasChanged;

            UseableEntityDetector = new MyEntityDetector();
            UseableEntityDetector.Init(null, new MyMwcObjectBuilder_EntityDetector(new Vector3(MySmallShipConstants.DETECT_SHIP_RADIUS * 2f, 0f, 0f), MyMwcObjectBuilder_EntityDetector_TypesEnum.Sphere), this, WorldMatrix, useableEntityCriterias);
            UseableEntityDetector.OnNearestEntityChange += OnNearestDetectedEntityChanged;
            UseableEntityDetector.OnNearestEntityCriteriasChange += OnNearestDetectedEntityCriteriasChanged;
        }
開發者ID:Bunni,項目名稱:Miner-Wars-2081,代碼行數:86,代碼來源:MySmallShip.cs

示例2: CreateDetectorForParticleEffect

        void CreateDetectorForParticleEffect()
        {
            m_smallShipDetector = new MyEntityDetector();

            m_smallShipDetector.Init(
                null,
                new MyMwcObjectBuilder_EntityDetector(
                    new Vector3(MyDummyPointConstants.PARTICLE_DETECTOR_SIZE * UserScale, 0, 0),
                    MyMwcObjectBuilder_EntityDetector_TypesEnum.Sphere),
                this,
                WorldMatrix,
                new List<IMyEntityDetectorCriterium>());

            m_smallShipDetector.Save = false;
            m_smallShipDetector.SetSensorDetectRigidBodyTypes(MyConstants.RIGIDBODY_TYPE_SHIP);

            m_smallShipDetector.On();
        }
開發者ID:Bunni,項目名稱:Miner-Wars-2081,代碼行數:18,代碼來源:MyDummyPoint.cs


注:本文中的MinerWars.AppCode.Game.Entities.EntityDetector.MyEntityDetector.Init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。