示例#1
0
 public virtual void Awake()
 {
     if (CheckErrors() == true)
     {
         return;
     }
     if (receivingObject)
     {
         platformScript            = receivingObject.GetComponent <MF_AbstractPlatform>();
         navScript                 = receivingObject.GetComponent <MF_AbstractNavigation>();
         receivingControllerScript = receivingObject.GetComponent <MF_AbstractPlatformControl>();
     }
     if (dontAddToSelectScript == false)
     {
         MF_AbstractSelection selScript = transform.root.GetComponent <MF_AbstractSelection>();
         if (selScript)
         {
             MF_AbstractTargeting[] temp = new MF_AbstractTargeting[selScript.otherTargScripts.Length + 1];
             for (int i = 0; i < selScript.otherTargScripts.Length; i++)
             {
                 temp[i] = selScript.otherTargScripts[i];
             }
             temp[selScript.otherTargScripts.Length] = this;
             selScript.otherTargScripts = temp;
         }
     }
 }
示例#2
0
 public virtual void Add(int key, MF_AbstractSelection script)
 {
     if (detectingMeList.ContainsKey(key) == false)
     {
         detectingMeList.Add(key, script);
         DoVisibility();
     }
 }
示例#3
0
    void Awake()
    {
        if (CheckErrors() == true)
        {
            return;
        }

        selectionScript = transform.root.GetComponent <MF_AbstractSelection>();
        instanceID      = cScript.gameObject.GetInstanceID();

        loaded = true;
        BuildLayermask();
    }
示例#4
0
    public virtual bool CheckErrors()
    {
        error = false;

        if (!selectionScript)
        {
            selectionScript = UtilityMF.GetComponentInParent <MF_AbstractSelection>(transform);
            if (selectionScript == null)
            {
                Debug.Log(this + ": No selection script found."); error = true;
            }
        }

        return(error);
    }
示例#5
0
    bool SetScanMark(GameObject mark, bool exception, MFnum.MarkType type)
    {
        MF_AbstractSelection sScript = selectionManager.sScript;
        bool set = false;

        if (mark)             // make sure mark exsists
        {
            if (exception == false)
            {
                if (sScript && sScript != this && sScript.showTargeting == true)         // self is not selected
                {
                    if (detectingMeList.ContainsKey(sScript.myId))                       // search if selected unit is detecting me
                    {
                        if (type == MFnum.MarkType.Analyzed)                             // check if analyzed
                        {
                            if (sScript.targetListScript.ContainsKey(myId))
                            {
                                if (sScript.targetListScript.GetDataLingerTime(myId) >= Time.time)
                                {
                                    set = true;
                                }
                            }
                            else
                            {
                                set = true;
                            }
                        }
                        else if (type == MFnum.MarkType.Detected)                               // check detection only
                        {
                            set = true;
                        }
                        else if (type == MFnum.MarkType.PoI)                               // check if poi
                        {
                            set = sScript.targetListScript.GetPoi(myId);
                        }
                    }
                }
            }
            mark.SetActive(set);
        }
        return(set);
    }
示例#6
0
    public virtual bool CheckErrors()
    {
        error = false;

        Transform rps;

        if (!selectionScript)
        {
            rps = UtilityMF.RecursiveParentComponentSearch("MF_AbstractSelection", transform);
            if (rps != null)
            {
                selectionScript = rps.GetComponent <MF_AbstractSelection>();
            }
            else
            {
                Debug.Log(this + ": No selection script found."); error = true;
            }
        }

        return(error);
    }
示例#7
0
    public override void OnMouseOver()
    {
        if (error)
        {
            return;
        }

        if (Input.anyKeyDown)
        {
            // cache references
            sObject = selectionManagerScript.selectedObject;
            sScript = selectionManagerScript.selectedObjScript;

            if (Input.GetKey(KeyCode.Mouse0))                                                                                 // left click
            {
                if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) || Input.GetKey(KeyCode.LeftControl)) // holding shift or control
                {
                    ShiftClick();
                }
                else                     // not holding shift or control
                {
                    LeftClick();
                }
            }
            if (Input.GetKey(KeyCode.Mouse1))
            {
                if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))                     // holding shift
                // nothing
                {
                }
                else                     // not holding shift
                {
                    ShiftClick();
                }
            }
        }
    }
示例#8
0
 public virtual void Awake()
 {
     selectionScript = GetComponent <MF_AbstractSelection>();
 }
示例#9
0
    void DoMarks()
    {
        if (error)
        {
            return;
        }

        MF_AbstractSelection sScript = selectionManager.sScript;

        bool _foundAsSelected   = false;
        bool _foundAsWeapTarget = false;
        bool _foundNav          = false;
        bool _foundAsPoi        = false;
        bool _foundAsAnalyzed   = false;

        if (selectedMark)
        {
            bool _showingSelected = false;
            if (selectionManager.sScript == this)                 // selected unit
            {
                _foundAsSelected = true;
                if (showSelected == true)
                {
                    _showingSelected = true;
                }
            }
            selectedMark.SetActive(_showingSelected);
        }

        if (navTargetMark && navigationScript)
        {
            if (showNavigation == true && navigationScript.navTarget)
            {
                if (_foundAsSelected == true)
                {
                    navTargetMark.transform.position = navigationScript.navTarget.transform.position;
                    _foundNav = true;
                }
            }
            navTargetMark.SetActive(_foundNav);
        }

        if (weaponTargetMark)
        {
            if (sScript && sScript != this && sScript.showTargeting == true)
            {
                if (detectingMeList.ContainsKey(sScript.myId) == true)                       // make sure selected unit is still detecting me (timing when going out of range - targeting script nulls target after)
                {
                    if (sScript.targetingScript && sScript.targetingScript.target == gameObject)
                    {
                        _foundAsWeapTarget = true;
                    }
                    for (int i = 0; i < sScript.otherTargScripts.Length; i++)                       // see if any of the selected unit's targeting scripts are targeting me
                    {
                        if (sScript.otherTargScripts[i].target == gameObject)
                        {
                            _foundAsWeapTarget = true;
                            break;
                        }
                    }
                }
            }
            weaponTargetMark.SetActive(_foundAsWeapTarget);
        }

        _foundAsPoi      = SetScanMark(poiMark, false, MFnum.MarkType.PoI);
        _foundAsAnalyzed = SetScanMark(analyzedMark, _foundAsPoi, MFnum.MarkType.Analyzed);
        SetScanMark(detectedMark, (_foundAsAnalyzed || _foundAsPoi), MFnum.MarkType.Detected);
    }
示例#10
0
//	public struct PoinOfInterest { // point of interest
//		public bool isPoi;
//		public float endTime;
//		public float prox;
//	}

    public virtual void Awake()
    {
        selectionScript = transform.root.GetComponent <MF_AbstractSelection>();
    }