コード例 #1
0
        public override void Execute(ShipContext context)
        {
            //Debug.Log($"In randomly orbit action");
            if (context.targetComp.target != null)
            {
                var AIShipComp = context.AiShipComp;
                AIShipComp.Navigation.SetNavState(EAINavState.ORBIT);
                AIShipComp.Navigation.HasReachedTarget = false;
                //AiShipComp.TargetPositionOffset = ZenUtils.Vec3Util.GetRandomVector(3, 3, 3);
                //AiShipComp.TargetPositionOffset = GetRandomOrbitPosition(15, 6);

                //Find new orbit point with no immediate collisions
                bool FoundFreePoint = false;
                while (!FoundFreePoint)
                {
                    //Try getting vector on the other side of the target diff
                    AIShipComp.Navigation.TargetPositionOffset = (context.targetComp.target.position - context.transform.position)
                                                                 + GetRandomOrbitPosition(MinOrbitRange, MaxOrbitRange);
                    if (!Physics.Linecast(context.transform.position,
                                          context.targetComp.target.position + AIShipComp.Navigation.TargetPositionOffset,
                                          ZenUtils.LayerMaskFromIDs(SRLayers.foreground, SRLayers.npc, SRLayers.player)))
                    {
                        FoundFreePoint = true;
                    }
                    else
                    {
                        Debug.Log("Point is collision course");
                    }
                }
            }
        }
コード例 #2
0
        //private Highlighter targetHighlighter;
        //private GameObject radarRIDGO;
        //private FX_3DRadar_RID radarRID;

        public override bool Init()
        {
            player              = engine.FindEntity(Res.Entities.Player);
            cam                 = Camera.main;
            targetComp          = player.GetComponent <TargetComp>();
            selectableLayerMask = ZenUtils.LayerMaskFromIDs(SRLayerMask.npc, SRLayerMask.foreground);

            player.GetComponent <CommandComp>().SelectTarget.Where(x => x).Subscribe(SelectTargetClicked);
            //radarRIDGO = GameObject.Find("Target_1");
            //radarRID = radarRIDGO.GetComponent<FX_3DRadar_RID>();
            return(false);
        }