예제 #1
0
 void CheckClicked()         //Handle raycast, if we hit an agent select them , if not add waypoints to previously selected agent
 {
     if (!EventSystem.current.IsPointerOverGameObject())
     {
         RaycastHit tHit;
         if (Input.GetMouseButtonDown(0))
         {
             if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out tHit))
             {
                 WayPointList tWPList = tHit.collider.gameObject.GetComponent <WayPointList> ();
                 Debug.DrawRay(tHit.point, Vector3.up * 3f, Color.red);         //Debug
                 if (tWPList != null)                                           //If this is an agent, then we can select it
                 {
                     mCurrentSelected = tWPList;
                 }
                 else                                                    //If not add we have one selected from before add more waypoints
                 {
                     if (mCurrentSelected != null)
                     {
                         Color tColour = mCurrentSelected.gameObject.GetComponentInChildren <MeshRenderer> ().material.color;
                         mCurrentSelected.Add(tHit.point, tColour);
                     }
                 }
             }
         }
     }
 }
예제 #2
0
    private void CreateAndSavePrefab()
    {
        GameObject objectPrefab = new GameObject(PrefabName);

        WayPointList scriptRef = objectPrefab.AddComponent <WayPointList>() as WayPointList;

        //int length = WayPointManager.Instance.mWayPointEditList.GetLength (0);
        int length = NumPointsUsed;

        scriptRef.InitList(length);
        scriptRef.HasData = HasData;
        for (int i = 0; i < length; i++)
        {
            Vector3 vec = WayPointManager.Instance.mWayPointEditList [i].transform.position;
            scriptRef.AddVector3(vec, i);

            if (HasData == true)
            {
                WayPoint wp = WayPointManager.Instance.mWayPointEditStructs [i];
                scriptRef.AddWayPointData(wp, i);
            }
        }
        scriptRef.PrefabName    = PrefabName;
        scriptRef.NumPointsUsed = NumPointsUsed;

        UnityEngine.Object prefab = PrefabUtility.CreateEmptyPrefab("Assets/Resources/Prefabs/WayPoints/" + objectPrefab.name + ".prefab");
        PrefabUtility.ReplacePrefab(objectPrefab, prefab, ReplacePrefabOptions.ConnectToPrefab);
    }
    private void LoadAttackManifest()
    {
        string manifestName = "ManifestListArea1";

        GameObject _meObj = Instantiate(Resources.Load("Prefabs/Manifests/" + manifestName, typeof(GameObject))) as GameObject;

        ManifestList manifestScript = _meObj.GetComponent <ManifestList> ();

        int numEntries = manifestScript.NumEntriesUsed;

        Debug.Log("LoadAttackManifest : numEntries = " + numEntries.ToString());

        int runningIndex = 0;

        for (int e = 0; e < numEntries; e++)
        {
            ManifestEntry me = manifestScript.GetManifestEntryAtIndex(e);

            int          numToLoad       = me.NumToLoad;
            string       alienPrefabName = me.PrefabName;
            WayPointList startingPoints  = me.StartingPoints;

            GameObject           _moduleDataObj = Instantiate(Resources.Load("Prefabs/AlienModuleData/" + alienPrefabName, typeof(GameObject))) as GameObject;
            AlienModuleContainer amc            = _moduleDataObj.GetComponent <AlienModuleContainer> ();
            AlienModuleData      amd            = amc.mData;

            for (int i = 0; i < numToLoad; i++)
            {
                GameObject _aaObj = Instantiate(Resources.Load("Prefabs/AlienAttackObject", typeof(GameObject))) as GameObject;

                if (_aaObj != null)
                {
                    if (AlienAttackObjectContainer != null)
                    {
                        _aaObj.transform.parent = AlienAttackObjectContainer.transform;
                    }
                    _aaObj.name = "attackObj" + runningIndex.ToString();


                    Vector3 startingVec = startingPoints.GetVector3AtIndex(i);
                    //Debug.Log("vec = " + startingVec.x.ToString() + " "  + startingVec.y.ToString() + " " + startingVec.z.ToString());

                    AlienAttackObject objectScript = _aaObj.GetComponent <AlienAttackObject> ();
                    objectScript.StoragePosition = StoragePoint.transform.position;
                    objectScript.StartPosition   = startingVec;
                    objectScript.AttachModuleData(amd);
                    objectScript.FixUp();

                    //temp test
                    objectScript.SetBaseSpriteScale(0.3f, 0.3f);

                    AlienAttackObjectList.Add(_aaObj);

                    runningIndex++;
                }
            }
        }
    }
예제 #4
0
        /// <summary>
        /// Create a basic boss
        /// </summary>
        /// <param name="tex">Boss textures</param>
        /// <param name="position">inital position</param>
        /// <param name="velocity">inital velocity</param>
        public Boss(Texture2D tex, Vector2 position, Vector2 velocity) : base(tex, position, velocity)
        {
            // Initialize our boss
            bState = BossState.Phase1;
            addBehaviour(BossShoot());
            addBehaviour(BossMove());

            // Initialize our waypoint list used for phase 2
            wl = new WayPointList();

            // Make waypoint list
            wl.makePathCircle(Game1.screenSize / 2, 225, -Util.degToRad(90), Util.degToRad(20), 18, 2, 1);
            sprite.wayList = wl;
        }
예제 #5
0
 void setSys5()
 {
     p = new ParticleSystem(ballPos, 60, 999, 105);
     p.setMandatory1(tex, new Vector2(6, 6), new Vector2(12, 12), Color.OrangeRed, new Color(50, 50, 50, 50));
     p.setMandatory2(60, 40, 20, 2, 0);
     // rectangle = new Rectangle(500 - 40, 390 - 30, 80, 50);
     p.setMandatory3(40, rectangle);
     p.setMandatory4(new Vector2(0, 0.08f), new Vector2(0, -1.5f), new Vector2(2, 1));
     p.randomDelta = new Vector2(0.01f, 0.01f);
     p.Origin      = 0;
     //p.originWayList = new WayPointList();
     //p.originWayList.makePathZigZag(new Vector2(100, 500), new Vector2(700, 500), new Vector2(0, 0), 3, 3);
     p.activate();
     wl = null;
 }
예제 #6
0
 void setSys2()
 {
     p = new ParticleSystem(new Vector2(300, 100), 40, 900, 107);
     p.setMandatory1(tex, new Vector2(6, 6), new Vector2(24, 24), Color.White, new Color(255, 255, 255, 100));
     p.setMandatory2(-1, 1, 1, 3, 0);
     // rectangle = new Rectangle(0, 0, 800, 600);
     p.setMandatory3(120, rectangle);
     p.setMandatory4(new Vector2(0, 0.1f), new Vector2(0, 0), new Vector2(1, 0));
     p.randomDelta     = new Vector2(0.1f, 0.1f);
     p.Origin          = 1;
     p.originRectangle = new Rectangle(0, 0, 800, 10);
     p.moveTowards     = 3;
     p.moveTowardsPos  = new Vector2(mouse_x, mouse_y);
     p.moveToDrift     = 0.1f;
     p.activate();
     wl = null;
 }
예제 #7
0
    public void FixUp()
    {
        SetPrimarySprite(mModuleData.PrimarySprite);


        //----------------------Way Points---------------------------
        if (mWayPointList == null)
        {
            mWayPointList = new WayPointList();
        }

        mWayPointList = mModuleData.WayPointList;

        mMaxWayPointCount = mWayPointList.NumPointsUsed;

        //mWayPointList.DebugPrintList ("####  BEFORE  ####");

        Vector3 startingWayPoint = mWayPointList.GetVector3AtIndex(0);

        WayPointOffset = _startPosition - startingWayPoint;

        //debug
        //startingOffset.x = -2f;
        //startingOffset.y = -2f;

        //startingOffset.z = 0f;
        //mWayPointList.AddOffsetToPointList (startingOffset);

        //mWayPointList.DebugPrintList ("####  AFTER  ####");



        //------------------------Color-----------------------
        if (mColorSet == null)
        {
            mColorSet = new ColorSet();
        }

        mColorSet = mModuleData.ColorSet;
        SetPrimarySpriteColor(mColorSet.PrimaryColour);
    }
예제 #8
0
    private static void EditSelectedWayPoint()
    {
        GameObject selectedGameObject = Selection.activeGameObject;

        Debug.Log("selectedGameObject = " + selectedGameObject.name);

        //this is the WayPointList
        WayPointList wpList = selectedGameObject.GetComponent <WayPointList> ();


        //this is the WayPointManager
        GameObject      WayPointManagerObject = GameObject.Find("WayPointManager");
        WayPointManager wpManager             = WayPointManagerObject.GetComponent <WayPointManager> ();
        string          pName     = wpManager.PrefabName;
        int             numPoints = wpList.NumPointsUsed;
        bool            HasData   = wpList.HasData;

        wpManager.PrefabName    = wpList.PrefabName;
        wpManager.NumPointsUsed = wpList.NumPointsUsed;
        wpManager.HasData       = wpList.HasData;

        Debug.Log("EditSelectedWayPoint : numPoints = " + numPoints);
        for (int i = 0; i < numPoints; i++)
        {
            Vector3 vec = wpList.GetVector3AtIndex(i);
            WayPointManager.Instance.mWayPointEditList [i].transform.position = new Vector3(vec.x, vec.y, vec.z);

            if (HasData == true)
            {
                WayPoint wp = wpList.GetWayPointDataAtIndex(i);
                WayPointManager.Instance.mWayPointEditStructs [i] = wp;
            }
        }

        Debug.Log("wpManager pName = " + pName);
    }
예제 #9
0
 // Use this for initialization
 void Start()
 {
     mWP = GetComponent <WayPointList>();
 }