// Use this for initialization
 public void Awake()
 {
     LevelSettings buildableResources = GameObject.Find("GameSettings").GetComponent<GameSettingsScript>().availableResources;
     availableResources = new LevelSettings(buildableResources.bananas,buildableResources.obstacles,buildableResources.monkeys,buildableResources.figures,new Goal());
     //availableResources = new LevelSettings(true,true,true,true, new Goal());
     statHandler = GameObject.Find("InitHolder").GetComponent<InitScript>();
 }
Example #2
0
    void Awake()
    {
        QualitySettings.vSyncCount  = 0;
        Application.targetFrameRate = 60;
        if (main == null)
        {
            main = this;
        }
        else if (main != this)
        {
            Destroy(gameObject);
        }

        // Initiate Game Variables
        InitScript init = new InitScript();

        availableBlocks = init.readBlocks();
        dimension       = init.readDimension();
        blockPrefab     = Resources.Load("Prefab/BlockPrefab") as GameObject;

        // Initiate Tick Variables
        storeTick = tick;
        isTick    = false;

        currentDimension = dimension[0];

        player = GameObject.Find("Player").GetComponent <PlayerScript>();
        //Perks.PerkSystem.InitPerks();
        GameObject.Find("GameManager").GetComponent <SaveScript>().StoreData();
    }
Example #3
0
        public Bouncing_Test()
        {
            InitScript.Init();

            entityFactory = new EntityFactory();
            Transform.AddTo(entityFactory, Layers.REAL, TransformFlags.Default);
            Stats.AddTo(entityFactory, Registry.Global.Stats._map);
            Displaceable.AddTo(entityFactory, Layers.BLOCK).DefaultPreset();
            Pushable.AddTo(entityFactory).DefaultPreset();
        }
Example #4
0
    // Use this for initialization
    void Awake()
    {
        Application.targetFrameRate = 60;
        Instance      = this;
        RestLifeTimer = PlayerPrefs.GetFloat("RestLifeTimer");
        DateOfExit    = PlayerPrefs.GetString("DateOfExit", "");
        print(DateOfExit);
        Gems  = PlayerPrefs.GetInt("Gems");
        lifes = PlayerPrefs.GetInt("Lifes");
        if (PlayerPrefs.GetInt("Lauched") == 0)               //First lauching
        {
            lifes = CapOfLife;
            PlayerPrefs.SetInt("Lifes", lifes);
            Gems = FirstGems;
            PlayerPrefs.SetInt("Gems", Gems);
            PlayerPrefs.SetInt("Music", 1);
            PlayerPrefs.SetInt("Sound", 1);

            PlayerPrefs.SetInt("Lauched", 1);
            PlayerPrefs.Save();
        }
        rate = Instantiate(Resources.Load("Prefabs/Rate")) as GameObject;
        rate.SetActive(false);
        rate.transform.SetParent(GameObject.Find("CanvasGlobal").transform);
        rate.transform.localPosition = Vector3.zero;
        rate.GetComponent <RectTransform> ().anchoredPosition = (Resources.Load("Prefabs/Rate") as GameObject).GetComponent <RectTransform> ().anchoredPosition;
        rate.transform.localScale = Vector3.one;

        GameObject.Find("Music").GetComponent <AudioSource> ().volume = PlayerPrefs.GetInt("Music");
        SoundBase.Instance.GetComponent <AudioSource> ().volume       = PlayerPrefs.GetInt("Sound");

#if GOOGLE_MOBILE_ADS
#if UNITY_ANDROID
        interstitial = new InterstitialAd(admobUIDAndroid);
#elif UNITY_IOS
        interstitial = new InterstitialAd(admobUIDIOS);
#else
        interstitial = new InterstitialAd(admobUIDAndroid);
#endif

        // Create an empty ad request.
        requestAdmob = new AdRequest.Builder().Build();
        // Load the interstitial with the request.
        interstitial.LoadAd(requestAdmob);
        interstitial.OnAdLoaded       += HandleInterstitialLoaded;
        interstitial.OnAdFailedToLoad += HandleInterstitialFailedToLoad;
#endif
        Transform canvas = GameObject.Find("CanvasGlobal").transform;
        foreach (Transform item in canvas)
        {
            item.gameObject.SetActive(false);
        }
    }
Example #5
0
        public string reset()
        {
            InitScript init        = GameObject.Find("Ground").GetComponent <InitScript> ();
            string     instruction = init.reset();

            string fileName = "deprecated";

            this.snapshotID++;

            this.current = this.getCurrentObjectSystem();
            return(fileName + "#" + instruction);
        }
Example #6
0
        public Slide_Tests()
        {
            InitScript.Init();
            entityFactory = new EntityFactory();
            Transform.AddTo(entityFactory, Layers.REAL, TransformFlags.Default);
            Stats.AddTo(entityFactory, Registry.Global.Stats._map);

            Ticking.AddTo(entityFactory).DefaultPreset();
            Displaceable.AddTo(entityFactory, Layers.BLOCK).DefaultPreset();
            Moving.AddTo(entityFactory).DefaultPreset();
            Pushable.AddTo(entityFactory).DefaultPreset();
            Acting.AddTo(entityFactory, null, Algos.SimpleAlgo, Order.Entity).DefaultPreset(entityFactory);
        }
    void OnLevelWasLoaded(int level)
    {
        //if (isfirst) {
        //isfirst = false;
//			#if UNITY_EDITOR
        Material m = Resources.Load("Materials/BLUEarmmat") as Material;

        m = Resources.Load("Materials/PURPLEarmmat") as Material;
        m = Resources.Load("Materials/REDarmmat") as Material;
        m = Resources.Load("Materials/GREENarmmat") as Material;
        m = Resources.Load("Materials/BROWNarmmat") as Material;
        m = Resources.Load("Materials/CYANarmmat") as Material;
        m = Resources.Load("Materials/ORANGEarmmat") as Material;
        m = Resources.Load("Materials/PEACHarmmat") as Material;
        m = Resources.Load("Materials/PINKarmmat") as Material;
        m = Resources.Load("Materials/YELLOWarmmat") as Material;
        //#endif
        //}


        // reset all static variables!!
        listOfChars   = new List <CharFuncs>();
        listOfCharObj = new List <GameObject>();
        listOfAllObj  = new List <GameObject>();
        listOfPawnObj = new List <GameObject>();
        //human = null;
        //humanfunc = null;

        priorityList = new List <GameObject>();

        globalQueue = new List <QueueObj>();
        isfirst     = true;

        // scrolling script variables
        showwarning       = false;
        targetTopAllText  = 0f;
        currentTopAllText = 0f;
        boxTop            = 0f;
        boxHeight         = 0f;

        hasspeech    = false;
        ready        = false;
        toDeleteList = new List <GameObject>();

        InitScript.LoadChars();
        //RunPlay();
        InitScript currentinit = Camera.main.GetComponent <InitScript>();

        currentinit.starting = true;
        currentinit.timer    = 0.0f;
    }
    //----------------------------------------------------


    // Start is called before the first frame update
    void Start()
    {
        //GameObject mobObj = GameObject.Find("Mob");
        //List<mobObj> mobList;

        GameObject initial    = GameObject.Find("init");
        InitScript intiscript = initial.GetComponent <InitScript>();

        enemyArray = intiscript.enemies;

        rb2D     = gameObject.GetComponent <Rigidbody2D>();
        velocity = new Vector2(0f, 0f);
        hitBox   = GetComponent <CircleCollider2D>();
    }
Example #9
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject initial    = GameObject.Find("init");
        InitScript intiscript = initial.GetComponent <InitScript>();

        enemyArray = intiscript.enemies;

        //ourUI = GameObject.Find("playerUI");
        //scoreText = ourUI.GetComponent<TextMeshProUGUI>();
        //st = ourUI.GetComponent<TextMeshPro>();

        p  = GameObject.Find("player");
        ph = p.GetComponent <pHealth>();
    }
Example #10
0
    // Use this for initialization
    void Awake()
    {
        Application.targetFrameRate = 60;
        Instance      = this;
        RestLifeTimer = PlayerPrefs.GetFloat("RestLifeTimer");
        DateOfExit    = PlayerPrefs.GetString("DateOfExit", "");
        if (DateOfExit == "" || DateOfExit == default(DateTime).ToString())
        {
            DateOfExit = ServerTime.THIS.serverTime.ToString();
        }
        DebugLogKeeper.Init();
        Gems  = PlayerPrefs.GetInt("Gems");
        lifes = PlayerPrefs.GetInt("Lifes");
        if (PlayerPrefs.GetInt("Lauched") == 0)
        {    //First lauching
            lifes = CapOfLife;
            PlayerPrefs.SetInt("Lifes", lifes);
            Gems = FirstGems;
            PlayerPrefs.SetInt("Gems", Gems);
            PlayerPrefs.SetInt("Music", 1);
            PlayerPrefs.SetInt("Sound", 1);

            PlayerPrefs.SetInt("Lauched", 1);
            PlayerPrefs.Save();
        }
        rate = Instantiate(Resources.Load("Prefabs/Rate")) as GameObject;
        rate.SetActive(false);
        rate.transform.SetParent(MenuReference.THIS.transform);
        rate.transform.localPosition = Vector3.zero;
        rate.GetComponent <RectTransform>().offsetMin = new Vector2(-5, -5);
        rate.GetComponent <RectTransform>().offsetMax = new Vector2(5, 5);
//        rate.GetComponent<RectTransform>().anchoredPosition = (Resources.Load("Prefabs/Rate") as GameObject).GetComponent<RectTransform>().anchoredPosition;
        rate.transform.localScale = Vector3.one;
        var g = MenuReference.THIS.Reward.gameObject;

        g.SetActive(true);
        g.SetActive(false);

#if FACEBOOK
        FacebookManager fbManager = new GameObject("FacebookManager").AddComponent <FacebookManager>();
#endif
    }
Example #11
0
    // Use this for initialization
    void Start()
    {
        server = this.GetComponent <SocketServer> ();
        if (FirstCamera != null)
        {
            sssfc = FirstCamera.GetComponent <ScreenshotScript> ();
        }
        if (DepthCamera != null)
        {
            sssdc = DepthCamera.GetComponent <ScreenshotScript> ();
        }
        if (SphereCamera != null)
        {
            ssssc = SphereCamera.GetComponent <ScreenshotScript> ();
        }

        if (optionPanel == null)
        {
            optionPanel = GameObject.Find("InitialObject").GetComponent <InitScript> ();
        }
    }
Example #12
0
        public Bind_Tests()
        {
            InitScript.Init();

            entityFactory = new EntityFactory();
            Transform.AddTo(entityFactory, Layers.REAL, TransformFlags.Default);
            Stats.AddTo(entityFactory, Registry.Global.Stats._map);
            Attackable.AddTo(entityFactory, Attackness.ALWAYS);
            Damageable.AddTo(entityFactory, new Health(1)).DefaultPreset();
            Displaceable.AddTo(entityFactory, Layers.WALL | Layers.REAL).DefaultPreset();
            Moving.AddTo(entityFactory).DefaultPreset();
            // Cannot be bound unless it has MoreChains
            MoreChains.AddTo(entityFactory, Registry.Global.MoreChains._map);


            bindingFactory = new EntityFactory();
            Transform.AddTo(bindingFactory, Layers.REAL, TransformFlags.Default);
            Stats.AddTo(bindingFactory, Registry.Global.Stats._map);
            Binding.AddTo(bindingFactory, Layers.REAL, BoundEntityModifierDefault.Hookable).DefaultPreset();
            Damageable.AddTo(bindingFactory, new Health(1)).DefaultPreset();
            Attackable.AddTo(bindingFactory, Attackness.ALWAYS);
            // The death chain is also required
            MoreChains.AddTo(bindingFactory, Registry.Global.MoreChains._map);
        }
 // Use this for initialization
 void Awake()
 {
     this.gameObject.transform.eulerAngles = new Vector3(this.gameObject.transform.eulerAngles.x,Random.Range(0,359), this.gameObject.transform.eulerAngles.z);
     statHandler = GameObject.Find ("InitHolder").GetComponent<InitScript>();
 }
Example #14
0
    void Update()
    {
        if (this.first)
        {
            if (Screen.height != this.screenSize || Screen.width != this.screenSize)
            {
                return;
            }
            this.first = false;
        }
        else
        {
            return;
        }

        this.dataset = DatasetUtil.parseJson(this.dataFileName, this.decoration);
        //this.dataset = this.readFromInstructionFile ();

        /// Remove pairs of replicated state-end environments
        /// in simplified problem
        if (this.simplifiedProblem)
        {
            List <DataPoint> newDataset = new List <DataPoint> ();

            int oldDatasetSize = this.dataset.Count;
            for (int i = 0; i < oldDatasetSize; i++)
            {
                DataPoint dp         = this.dataset [i];
                Episode   eps        = dp.getEpisode();
                int       startIndex = dp.getStartFrame();
                int       endIndex   = dp.getEndFrame();

                bool seen = false;
                foreach (DataPoint newDp in newDataset)
                {
                    if (newDp.getStartFrame() == startIndex &&
                        newDp.getEndFrame() == endIndex &&
                        newDp.getEpisode() == eps)
                    {
                        seen = true;
                        break;
                    }
                }

                if (!seen)
                {
                    newDataset.Add(dp);
                }
            }

            this.dataset = newDataset;
            Debug.Log("After removing commons. The dataset file " +
                      this.dataFileName + " has size " + this.dataset.Count);
        }

        Debug.Log("Total dataset size " + this.dataset.Count);
        if (this.numDatapoints == -1)
        {
            this.numDatapoints = this.dataset.Count;
        }

        // Separate tune data and add it later
        List <DataPoint> tuning = new List <DataPoint> ();

        HashSet <Episode> epsLogo  = new HashSet <Episode> ();
        HashSet <Episode> epsDigit = new HashSet <Episode> ();

        for (int i = 0; i < this.dataset.Count; i++)
        {
            DataPoint  dp   = this.dataset [i];
            Decoration type = dp.getDecoration();
            Episode    eps  = dp.getEpisode();

            if (type == Decoration.Logos)
            {
                if (epsLogo.Contains(eps))
                {
                    tuning.Add(dp);
                }
                else if (epsLogo.Count < 2)
                {
                    //Space to add more episodes
                    epsLogo.Add(eps);
                    tuning.Add(dp);
                }
            }

            if (type == Decoration.Digits)
            {
                if (epsDigit.Contains(eps))
                {
                    tuning.Add(dp);
                }
                else if (epsDigit.Count < 2)
                {
                    // Space to add more episodes
                    epsDigit.Add(eps);
                    tuning.Add(dp);
                }
            }
        }

        this.cachedTraj = new CachedTrajectory();
        int datasetSize = this.dataset.Count;

        for (int i = 0; i < datasetSize; i++)
        {
            DataPoint dp         = this.dataset [i];
            Episode   eps        = dp.getEpisode();
            int       startIndex = dp.getStartFrame();
            int       endIndex   = dp.getEndFrame();
            if (!this.cachedTraj.isExist(eps, startIndex, endIndex))
            {
                ObjectSystem     system1    = eps.getEnvironmentByIndex(startIndex);
                ObjectSystem     toReach1   = eps.getEnvironmentByIndex(endIndex);
                TrajectoryResult trajResult = system1.findShortestPathAStar(toReach1);
                this.cachedTraj.addTrajectory(eps, startIndex, endIndex, trajResult);
            }
        }

        // Remove the tuning data
        foreach (DataPoint dp in tuning)
        {
            this.dataset.Remove(dp);
        }
        Debug.Log("Dataset: Tuning " + tuning.Count + " and train is " + this.dataset.Count);

        if (this.shuffleBeforeSelect)
        {
            InitScript.Shuffle(this.dataset);
        }

        // Add the tuning data in the beginning
        List <DataPoint> smallerDataset = new List <DataPoint> ();

        foreach (DataPoint dp in tuning)
        {
            smallerDataset.Add(dp);
        }

        //////////////////////////////////////
        List <SeenDemonstrations> uniqueDemonstration = new List <SeenDemonstrations>();

        foreach (DataPoint dp in this.dataset)
        {
            bool isSeen = this.isSeenDemonstration(uniqueDemonstration, dp.getEpisode(), dp.getStartFrame(), dp.getEndFrame());
            if (!isSeen)
            {
                SeenDemonstrations seen = new SeenDemonstrations(dp.getEpisode(), dp.getStartFrame(), dp.getEndFrame());
                uniqueDemonstration.Add(seen);
            }
        }

        // Number of demonstations to consider
        int toUse = (int)(this.percentDemonstrations * uniqueDemonstration.Count);

        Debug.Log("Number of demonstrations to are " + uniqueDemonstration.Count + " using " + toUse);

        List <SeenDemonstrations> usedDemonstrations = new List <SeenDemonstrations>();

        for (int i = 0; i < toUse; i++)
        {
            usedDemonstrations.Add(uniqueDemonstration [i]);
        }

        Debug.Log("Using " + usedDemonstrations.Count + " out of " + uniqueDemonstration.Count);

        List <DataPoint> dpsSeen   = new List <DataPoint>();
        List <DataPoint> dpsUnseen = new List <DataPoint> ();

        foreach (DataPoint dp in this.dataset)
        {
            if (this.isSeenDemonstration(usedDemonstrations, dp.getEpisode(), dp.getStartFrame(), dp.getEndFrame()))
            {
                dpsSeen.Add(dp);
            }
            else
            {
                dpsUnseen.Add(dp);
            }
        }

        Debug.Log("Size of seen dataset is " + dpsSeen.Count + " and unseen is " + dpsUnseen.Count);
        int total = tuning.Count + dpsSeen.Count + dpsUnseen.Count;

        Debug.Log("Total accounted points are " + total);

        foreach (DataPoint dp in dpsSeen)
        {
            smallerDataset.Add(dp);
        }

        foreach (DataPoint dp in dpsUnseen)
        {
            smallerDataset.Add(dp);
        }

        Debug.Log("Size of smaller dataset is " + smallerDataset.Count);
        this.numDatapointsWithDemonstrations = tuning.Count + dpsSeen.Count;
        Debug.Log("MAGIC: Consider the first " + this.numDatapointsWithDemonstrations + " points ");
        //////////////////////////////////////

        /*foreach (DataPoint dp in this.dataset) {
         *      smallerDataset.Add (dp);
         * }*/

        this.dataset = smallerDataset;

        // Start with the environment in the training data
        this.datapointIndex = 0;
        DataPoint        current          = this.dataset [this.datapointIndex];
        int              start            = current.getStartFrame();
        int              end              = current.getEndFrame();
        Episode          episode          = current.getEpisode();
        ObjectSystem     system           = episode.getEnvironmentByIndex(start);
        ObjectSystem     toReach          = episode.getEnvironmentByIndex(end);
        TrajectoryResult trajResult1      = this.cachedTraj.getTrajectory(episode, start, end);
        List <int>       trajectory       = trajResult1.getTrajectory();
        List <Point3D>   trajectoryPoints = trajResult1.getTrajectoryPoints();
        string           instruction      = current.getInstruction();
        Decoration       pointDecoration  = current.getDecoration();

        Debug.Log("Up and running");

        //Read the grid
        GameObject ground       = GameObject.Find("Ground");
        Bounds     groundBounds = ground.GetComponent <MeshFilter> ().mesh.bounds;
        float      groundWidth  = groundBounds.size.x;
        float      groundHeight = groundBounds.size.z;

        Debug.Log("Ground: Width " + groundWidth + " height " + groundHeight);

        //Read the sample cube information
        GameObject cube       = GameObject.Find("Cube");
        Bounds     cubeBounds = cube.GetComponent <MeshFilter> ().mesh.bounds;
        float      cubeWidth  = cubeBounds.size.x;
        float      cubeHeight = cubeBounds.size.z;

        Debug.Log("Cube: Width " + cubeWidth + " height " + cubeHeight);

        //Render the system
        this.logoCubes = this.createLogoCubes(system, cube);
        GameObject sampleDigits = GameObject.Find("Digits");

        this.digitCubes             = this.createDigitCubes(system, cube, sampleDigits);
        ground.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f) * 0.25f;
        this.render(system, pointDecoration);
        this.highlightMainBlockAndGoal(system, toReach);

        List <GameObject> cubes = null;

        if (pointDecoration == Decoration.Logos)
        {
            cubes = this.logoCubes;
        }
        else if (pointDecoration == Decoration.Digits)
        {
            cubes = this.digitCubes;
        }

        // Add robot controller
        GameObject robot = GameObject.Find("Robot");

        robot.AddComponent <RobotController> ();
        RobotController robotController = robot.GetComponent <RobotController> ();

        robotController.init(cubes, (float)system.getSizeOfBlock(), this.stepSize, this.horizon);

        // Initialize the MDP Manager which computes rewards.
        double gamma         = 0.1;
        double failureReward = -5;
        double winReward     = 5;

        robotController.initMDPManager(gamma, failureReward, winReward, this.stopActionReward,
                                       this.rewardFunctionType, this.simplifiedProblem, this.horizon);

        // Set the robot controller to work on the current problem
        robotController.changeEpisode(cubes, system, toReach, trajectory, trajectoryPoints, brandsList.Count, episode.getBlockSize());

        // Add agent messenger for listening
        AgentMessenger.uselocalhost = this.uselocalhost;
        robot.AddComponent <AgentMessenger> ();
        this.agentMessenger = robot.GetComponent <AgentMessenger> ();

        // Attach the robot controller to agent messenger
        this.agentMessenger.attachRobotController(robotController);

        //Find trajectory
        string s = "";

        foreach (int i in trajectory)
        {
            s = s + i + ",";
        }

        // TODO Clearly define message protocol
        StartCoroutine(initConnection("Reset#0#img/Screenshot.png#" + instruction + "#" + s));
//		StartCoroutine (sendMessageWithGoalState ("Reset#0#img/Screenshot.png#" + instruction + "#" + s));
    }
Example #15
0
    // Use this for initialization
    void Awake()
    {
        if(Application.platform == RuntimePlatform.WindowsEditor){
            Application.targetFrameRate = 60;
        //	PlayerPrefs.DeleteAll();
        //	Hat = true;
        //	InfinityLife = true;
        //	StickyStars = true;
            tutPassed = true;
        //			RestScores();
        }
        Beatedfriends =  new List<string>();
        Beatedfriends.Clear();

        //		if( !InitScript.WasInApp)
        //			ChartboostAd.Instance().LoadInterstitialAd(false);
        RestLifeTimer = PlayerPrefs.GetFloat("RestLifeTimer");
        DateOfExit = PlayerPrefs.GetString("DateOfExit");
        if(PlayerPrefs.GetInt("WasInApp") == 1)
            InitScript.WasInApp = true;

        if(PlayerPrefs.GetInt("Skin1") == 1)
            InitScript.Skin[1] = true;

        if(PlayerPrefs.GetInt("Skin2") == 1)
            InitScript.Skin[2] = true;

        if(PlayerPrefs.GetInt("Skin3") == 1)
            InitScript.Skin[3] = true;

        if(PlayerPrefs.GetInt("Skin4") == 1)
            InitScript.Skin[4] = true;

        if(PlayerPrefs.GetInt("Hat") == 1)
            InitScript.Hat = true;

        if(PlayerPrefs.GetInt("InfinityLife") == 1)
            InitScript.InfinityLife = true;

        if(PlayerPrefs.GetInt("StickyStars") == 1)
            InitScript.StickyStars = true;

        Inctance = this;
        Gems = PlayerPrefs.GetInt("Gems");
        //		if(PlayerPrefs.GetInt("tutPassed") == 1)
        //			tutPassed = true;

        if(PlayerPrefs.GetInt("Lauched") == 0){    //First lauching
            FirstTime = true;
            Gems = 10;
            PlayerPrefs.SetInt("Gems",Gems);
            PlayerPrefs.SetInt("Lauched", 1);
            PlayerPrefs.Save();
        }

        // see if we've got game music still playing
        GameObject gameMusic = GameObject.Find("Music");
        //		if (gameMusic) {
        //			// kill game music
        //			Destroy(gameMusic);
        //		}
        // make sure we survive going to different scenes
        //	DontDestroyOnLoad(gameMusic);

        Invoke("DelayStart",0.001f);
    }
Example #16
0
        public void resetEnd()
        {
            InitScript init = GameObject.Find("Ground").GetComponent <InitScript> ();

            init.resetEnd();
        }
Example #17
0
    void Start()
    {
        instance = this;

        Go.defaultEaseType = EaseType.Linear;
        Go.duplicatePropertyRule = DuplicatePropertyRuleType.RemoveRunningProperty;

        bool isIPad = SystemInfo.deviceModel.Contains("iPad");

        FutileParams fparams = new FutileParams(false, false, true, false);

        fparams.AddResolutionLevel(480.0f, 1.0f, 1.0f,"");

        fparams.origin = new Vector2(0.5f, 0.5f);

        fparams.targetFrameRate = 60;
        Application.targetFrameRate = 60;

        Futile.instance.Init(fparams);

        Futile.atlasManager.LoadAtlas("Atlases/Sprites");

        FTouchManager.shouldMouseEmulateTouch = true;

        _stage = Futile.stage;

        //I have to say, unity makes it mad easy to store stuff like highscores on the device
        highScore = PlayerPrefs.GetInt("highscore", 0);
        hsD1 = PlayerPrefs.GetInt("Digit1",0);
        hsD2 = PlayerPrefs.GetInt("Digit2",0);
        hsD3 = PlayerPrefs.GetInt("Digit3",0);

        //the black bars are added to the ipad version only, since it's pixel art
        //it doesn't scale in odd resolutions, so I just made the screen a better resolution essentially

        //it's a pretty horrible hack, but this is the only way I could really think to do it
        blackBar1 = new FSprite("blackbar.png");
        if (isIPad == false)
            blackBar1.SetElementByName("0.png");
        blackBar1.x = -320;
        blackBar1.scale = 2.0f;
        Futile.stage.AddChild(blackBar1);
        blackBar2 = new FSprite("blackbar.png");
        if (isIPad == false)
            blackBar2.SetElementByName("0.png");
        blackBar2.x = 320;
        blackBar2.scale = 2.0f;
        Futile.stage.AddChild(blackBar2);

        HandleResize();
        ISoundManager.Start();
        ISoundManager.PlayMusic();

        //gamecenter stuff that unity reduces to like 3 lines
        //very cool
        Social.localUser.Authenticate(authCallback);

        gotoMenu();
    }
Example #18
0
    // Use this for initialization
    void Awake()
    {
        Instance      = this;
        RestLifeTimer = PlayerPrefs.GetFloat("RestLifeTimer");

        DateOfExit = PlayerPrefs.GetString("DateOfExit", "");
        Gems       = PlayerPrefs.GetInt("Gems");
        lifes      = PlayerPrefs.GetInt("Lifes");
        if (PlayerPrefs.GetInt("Lauched") == 0)               //First lauching
        {
            lifes = CapOfLife;
            PlayerPrefs.SetInt("Lifes", lifes);
            Gems = FirstGems;
            PlayerPrefs.SetInt("Gems", Gems);
            PlayerPrefs.SetInt("Music", 1);
            PlayerPrefs.SetInt("Sound", 1);

            PlayerPrefs.SetInt("Lauched", 1);
            PlayerPrefs.Save();
        }
        rate = Instantiate(Resources.Load("Prefabs/Rate")) as GameObject;
        rate.SetActive(false);
        rate.transform.SetParent(GameObject.Find("CanvasGlobal").transform);
        rate.transform.localPosition = Vector3.zero;
        rate.GetComponent <RectTransform> ().anchoredPosition = (Resources.Load("Prefabs/Rate") as GameObject).GetComponent <RectTransform> ().anchoredPosition;
        rate.transform.localScale = Vector3.one;

        GameObject.Find("Music").GetComponent <AudioSource> ().volume = PlayerPrefs.GetInt("Music");
        SoundBase.Instance.GetComponent <AudioSource> ().volume       = PlayerPrefs.GetInt("Sound");

        if (Advertisement.isSupported)
        {
                        #if UNITY_ANDROID
            Advertisement.Initialize(unityAdsIDAndroid);
                        #elif UNITY_IOS
            Advertisement.Initialize(unityAdsIDIOS);
                        #else
            Advertisement.Initialize(unityAdsIDAndroid);
                        #endif
        }
                #if UNITY_ANDROID
        interstitial = new InterstitialAd(admobUIDAndroid);
                #elif UNITY_IOS
        interstitial = new InterstitialAd(admobUIDIOS);
                #else
        interstitial = new InterstitialAd(admobUIDAndroid);
                #endif



        // Create an empty ad request.
        requestAdmob = new AdRequest.Builder().Build();
        // Load the interstitial with the request.
        interstitial.LoadAd(requestAdmob);

        Transform canvas = GameObject.Find("CanvasGlobal").transform;
        foreach (Transform item in canvas)
        {
            item.gameObject.SetActive(false);
        }
    }
Example #19
0
    // Update is called once per frame
    void FixedUpdate()
    {
        /*if (Hamlet == null) {
         *      templist = GameObject.FindGameObjectsWithTag("Hamlet");
         *      Hamlet = templist[0];
         *      HamletFunc = (CharFuncs) Hamlet.GetComponent (typeof(CharFuncs));
         *      listOfChars.Add(HamletFunc);
         *      templist = null;
         * }
         * if (Horatio == null) {
         *      templist = GameObject.FindGameObjectsWithTag("Horatio");
         *      Horatio = templist[0];
         *      HoratioFunc = (CharFuncs) Horatio.GetComponent (typeof(CharFuncs));
         *      listOfChars.Add (HoratioFunc);
         *      templist = null;
         * }
         * if (GraveDigger == null) {
         *      templist = GameObject.FindGameObjectsWithTag("GraveDigger");
         *      GraveDigger = templist[0];
         *      GraveDiggerFunc = (CharFuncs) GraveDigger.GetComponent (typeof(CharFuncs));
         *      listOfChars.Add(GraveDiggerFunc);
         *      templist = null;
         * }
         * if (GraveDiggerTwo == null) {
         *      templist = GameObject.FindGameObjectsWithTag("GraveDiggerTwo");
         *      GraveDiggerTwo = templist[0];
         *      GraveDiggerTwoFunc = (CharFuncs) GraveDiggerTwo.GetComponent (typeof(CharFuncs));
         *      listOfChars.Add(GraveDiggerTwoFunc);
         *      templist = null;
         * }
         * if (Skull1 == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("Skull1");
         *      Skull1 = templist[0];
         *      templist = null;
         * }
         * if (Skull2 == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("Skull2");
         *      Skull2 = templist[0];
         *      templist = null;
         * }
         * if (Lantern == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("Lantern");
         *      Lantern = templist[0];
         *      templist = null;
         * }
         * if (Shovel == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("Shovel");
         *      Shovel = templist[0];
         *      templist = null;
         * }
         * if (Audience == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("Audience");
         *      Audience = templist[0];
         *      templist = null;
         * }
         * if (Grave == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("Grave");
         *      Grave = templist[0];
         *      templist = null;
         * }
         * if (StageRight == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("StageRight");
         *      StageRight = templist[0];
         *      templist = null;
         * }
         * if (CenterBackStage == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("CenterBackStage");
         *      CenterBackStage = templist[0];
         *      templist = null;
         * }
         * if (Center == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("Center");
         *      Center = templist[0];
         *      templist = null;
         * }
         * if (CenterRight == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("CenterRight");
         *      CenterRight = templist[0];
         *      templist = null;
         * }
         * if (DownStage == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("DownStage");
         *      DownStage = templist[0];
         *      templist = null;
         * }
         * if (StageLeft == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("StageLeft");
         *      StageLeft = templist[0];
         *      templist = null;
         * }
         * if (Steps == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("Steps");
         *      Steps = templist[0];
         *      templist = null;
         * }
         * if (Stool == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("Stool");
         *      Stool = templist[0];
         *      templist = null;
         * }
         * if (UpStage == null) {
         *      templist = GameObject.FindGameObjectsWithTag ("UpStage");
         *      UpStage = templist[0];
         *      templist = null;
         * }*/
        /*if (Box == null) {
         *      templist = GameObject.FindGameObjectsWithTag("Box");
         *      for (int i=0; i<templist.Length; i++) {
         *              if (templist[i].name == "Skull1") {
         *                      Box = templist[i];
         *              }
         *      }
         *      //Box = templist[0];
         *      templist = null;
         * }*/

        if (InitScript.started && GlobalObjs.globalQueue.Count == 0)
        {
            // read next set of lines
            Debug.Log("Calling next Step, no items in queue");
            InitScript.callNextStep();
        }
    }
        static void RunCommond()
        {
            lock (_lockRunLoop)
            {
                try
                {
                    List <tb_command_model> commands = new List <tb_command_model>();
                    try
                    {
                        SqlHelper.ExcuteSql(GlobalConfig.ConnectionString, (conn) =>
                        {
                            tb_command_dal commanddal = new tb_command_dal();
                            if (lastMaxID < 0)
                            {
                                lastMaxID = commanddal.GetMaxCommandID(conn);
                            }
                            commands = commanddal.GetNodeCommands(conn, GlobalConfig.NodeID, lastMaxID);
                        });
                    }
                    catch (Exception ex)
                    {
                        LogHelper.AddNodeError("获取当前节点命令集错误", ex);
                    }
                    if (commands.Count > 0)
                    {
                        LogHelper.AddNodeLog("当前节点扫描到" + commands.Count + "条命令,并执行中....");
                    }
                    foreach (var c in commands)
                    {
                        EnumTaskCommandState enumTaskCommandState = EnumTaskCommandState.Error;
                        EnumTaskState        enumTaskState        = EnumTaskState.UnInstall;
                        try
                        {
                            SqlHelper.ExcuteSql(GlobalConfig.ConnectionString, (conn) =>
                            {
                                tb_task_dal taskDAL = new tb_task_dal();
                                var task            = taskDAL.GetOneTask(conn, c.taskid);

                                tb_version_dal versionDAL = new tb_version_dal();
                                var version = versionDAL.GetVersionByTaskID(conn, c.taskid);

                                string path = $"{AppDomain.CurrentDomain.BaseDirectory}{task.taskname}";
                                if (!Directory.Exists(path))
                                {
                                    Directory.CreateDirectory(path);
                                    if (version != null)
                                    {
                                        string zipFilePath = $"{path}\\{version.zipfilename}";
                                        ///数据库二进制转压缩文件
                                        CompressHelper.ConvertToFile(version.zipfile, zipFilePath);
                                        CompressHelper.UnCompress(zipFilePath, path);
                                        ///删除压缩文件
                                        File.Delete(zipFilePath);
                                        ///初始化shell脚本
                                        InitScript.InstallScript(task.taskname, task.taskmainclassdllfilename);

                                        InitScript.UninstallScript(task.taskname);

                                        InitScript.StartScript(task.taskname);

                                        InitScript.StopScript(task.taskname);
                                    }
                                    else
                                    {
                                        throw new Exception($"在tb_version表中未查到taskid:{c.taskid}数据");
                                    }
                                }
                                if (c.commandname == EnumTaskCommandName.StartTask.Tostring())
                                {
                                    if (ServiceHelper.ServiceState(task.taskname) == EnumTaskState.UnInstall)
                                    {
                                        CommandFactory.Execute(path + "\\install.bat");
                                    }

                                    ///线程睡眠5s,等待服务安装完成
                                    Thread.Sleep(5000);
                                    CommandFactory.Execute(path + "\\start.bat");

                                    ///线程睡眠2s,等到脚本执行完成
                                    Thread.Sleep(2000);
                                    if (ServiceHelper.ServiceState(task.taskname) == EnumTaskState.Running)
                                    {
                                        enumTaskCommandState = EnumTaskCommandState.Success;
                                        enumTaskState        = EnumTaskState.Running;
                                    }
                                }
                                else if (c.commandname == EnumTaskCommandName.ReStartTask.Tostring())
                                {
                                    CommandFactory.Execute(path + "\\start.bat");
                                    ///线程睡眠2s,等到脚本执行完成
                                    Thread.Sleep(2000);
                                    if (ServiceHelper.ServiceState(task.taskname) == EnumTaskState.Running)
                                    {
                                        enumTaskCommandState = EnumTaskCommandState.Success;
                                        enumTaskState        = EnumTaskState.Running;
                                    }
                                }
                                else if (c.commandname == EnumTaskCommandName.StopTask.Tostring())
                                {
                                    CommandFactory.Execute(path + "\\stop.bat");

                                    ///线程睡眠2s,等到脚本执行完成
                                    Thread.Sleep(2000);
                                    if (ServiceHelper.ServiceState(task.taskname) == EnumTaskState.Stop)
                                    {
                                        enumTaskCommandState = EnumTaskCommandState.Success;
                                        enumTaskState        = EnumTaskState.Stop;
                                    }
                                }
                                else if (c.commandname == EnumTaskCommandName.UninstallTask.Tostring())
                                {
                                    if (ServiceHelper.ServiceState(task.taskname) == EnumTaskState.Running)
                                    {
                                        CommandFactory.Execute(path + "\\stop.bat");
                                        Thread.Sleep(2000);
                                    }
                                    CommandFactory.Execute(path + "\\uninstall.bat");

                                    ///线程睡眠2s,等到脚本执行完成
                                    Thread.Sleep(2000);
                                    if (ServiceHelper.ServiceState(task.taskname) == EnumTaskState.UnInstall)
                                    {
                                        enumTaskCommandState = EnumTaskCommandState.Success;
                                    }
                                }
                                ///更新命令状态
                                new tb_command_dal().UpdateCommandState(conn, c.id, (int)enumTaskCommandState);
                                ///更新服务状态
                                new tb_task_dal().UpdateTaskState(conn, c.taskid, (int)enumTaskState);

                                if (enumTaskCommandState == EnumTaskCommandState.Success)
                                {
                                    LogHelper.AddNodeLog($"节点:{c.nodeid}成功执行任务:{c.taskid}……");
                                }
                            });
                        }
                        catch (Exception ex)
                        {
                            LogHelper.AddTaskError("任务执行错误", c.taskid, ex);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.AddNodeLog($"节点执行错误,错误原因:{ex.Message}");
                }
            }
        }
 // Update is called once per frame
 void Update()
 {
     //if (statholder.settings)
     statholder = GameObject.Find("InitHolder").GetComponent<InitScript>();
 }
    // Use this for initialization
    void Awake()
    {
        Application.targetFrameRate = 60;
        Instance      = this;
        RestLifeTimer = PlayerPrefs.GetFloat("RestLifeTimer");
        DateOfExit    = PlayerPrefs.GetString("DateOfExit", "");
        print(DateOfExit);
        Gems  = PlayerPrefs.GetInt("Gems");
        lifes = PlayerPrefs.GetInt("Lifes");
        {//2.2.2 rewarded limit
            dailyRewardedShown     = new int[Enum.GetValues(typeof(RewardedAdsType)).Length];
            dailyRewardedShownDate = new DateTime[Enum.GetValues(typeof(RewardedAdsType)).Length];
            for (int i = 0; i < dailyRewardedShown.Length; i++)
            {
                dailyRewardedShown[i]     = PlayerPrefs.GetInt(((RewardedAdsType)i).ToString());
                dailyRewardedShownDate[i] = DateTimeManager.GetLastDateTime(((RewardedAdsType)i).ToString());
            }
        }
        if (PlayerPrefs.GetInt("Lauched") == 0)
        {    //First lauching
            lifes = CapOfLife;
            PlayerPrefs.SetInt("Lifes", lifes);
            Gems = FirstGems;
            PlayerPrefs.SetInt("Gems", Gems);
            PlayerPrefs.SetInt("Music", 1);
            PlayerPrefs.SetInt("Sound", 1);

            PlayerPrefs.SetInt("Lauched", 1);
            PlayerPrefs.Save();
        }
        rate = Instantiate(Resources.Load("Prefabs/Rate")) as GameObject;
        rate.SetActive(false);
        rate.transform.SetParent(GameObject.Find("CanvasGlobal").transform);
        rate.transform.localPosition = Vector3.zero;
        rate.GetComponent <RectTransform>().anchoredPosition = (Resources.Load("Prefabs/Rate") as GameObject).GetComponent <RectTransform>().anchoredPosition;
        rate.transform.localScale = Vector3.one;

        if (gameObject.GetComponent <AspectCamera>() == null)
        {
            gameObject.AddComponent <AspectCamera>().map = FindObjectOfType <LevelsMap>().transform.Find("map_background_01").GetComponent <SpriteRenderer>().sprite;                                               //gameObject.AddComponent<AspectCamera>().topPanel = GetComponent<LevelManager>().Level.transform.Find("Canvas/Panel/Panel/Panel").GetComponent<RectTransform>();//2.2.2
        }
        GameObject.Find("Music").GetComponent <AudioSource>().volume = PlayerPrefs.GetInt("Music");
        SoundBase.Instance.GetComponent <AudioSource>().volume       = PlayerPrefs.GetInt("Sound");

#if UNITY_ADS//2.1.1
        enableUnityAds = true;
#else
        enableUnityAds = false;
#endif
#if CHARTBOOST_ADS//1.6.1
        enableChartboostAds = true;
#else
        enableChartboostAds = false;
#endif

#if FACEBOOK
        FacebookManager fbManager = gameObject.AddComponent <FacebookManager>();
        fbManager.facebookButton = facebookButton;
#endif


#if GOOGLE_MOBILE_ADS
        enableGoogleMobileAds = true;          //1.6.1
#if UNITY_ANDROID
        MobileAds.Initialize(admobUIDAndroid); //2.1.6
        interstitial = new InterstitialAd(admobUIDAndroid);
#elif UNITY_IOS
        MobileAds.Initialize(admobUIDIOS);//2.1.6
        interstitial = new InterstitialAd(admobUIDIOS);
#else
        MobileAds.Initialize(admobUIDAndroid);//2.1.6
        interstitial = new InterstitialAd(admobUIDAndroid);
#endif

        // Create an empty ad request.
        requestAdmob = new AdRequest.Builder().Build();
        // Load the interstitial with the request.
        interstitial.LoadAd(requestAdmob);
        interstitial.OnAdLoaded       += HandleInterstitialLoaded;
        interstitial.OnAdFailedToLoad += HandleInterstitialFailedToLoad;
#else
        enableGoogleMobileAds = false;//1.6.1
#endif
        Transform canvas = GameObject.Find("CanvasGlobal").transform;
        foreach (Transform item in canvas)
        {
            item.gameObject.SetActive(false);
        }
    }
Example #23
0
 void OnFocus()
 {
     initscript = Camera.main.GetComponent <InitScript>();
 }
Example #24
0
    // Use this for initialization
    void Awake()
    {
        //Application.targetFrameRate = 60;
        Instance      = this;
        RestLifeTimer = PlayerPrefs.GetFloat("RestLifeTimer");
        DateOfExit    = PlayerPrefs.GetString("DateOfExit", "");
        //print(DateOfExit);
        Gems  = PlayerPrefs.GetInt("Gems");
        lifes = PlayerPrefs.GetInt("Lifes");
        if (PlayerPrefs.GetInt("Lauched") == 0)
        {    //First lauching
            lifes = CapOfLife;
            PlayerPrefs.SetInt("Lifes", lifes);
            Gems = FirstGems;
            PlayerPrefs.SetInt("Gems", Gems);
            PlayerPrefs.SetInt("Music", 1);
            PlayerPrefs.SetInt("Sound", 1);

            PlayerPrefs.SetInt("Lauched", 1);
            PlayerPrefs.Save();
        }
        //rate = Instantiate(Resources.Load("Prefabs/Rate")) as GameObject;
        //rate.SetActive(false);
        //rate.transform.SetParent(GameObject.Find("CanvasGlobal").transform);
        //rate.transform.localPosition = Vector3.zero;
        //rate.GetComponent<RectTransform>().anchoredPosition = (Resources.Load("Prefabs/Rate") as GameObject).GetComponent<RectTransform>().anchoredPosition;
        //rate.transform.localScale = Vector3.one;

        GameObject.Find("Music").GetComponent <AudioSource>().volume = PlayerPrefs.GetInt("Music");
        SoundBase.Instance.GetComponent <AudioSource>().volume       = PlayerPrefs.GetInt("Sound");

#if UNITY_ADS//2.1.1
        enableUnityAds = true;
#else
        enableUnityAds = false;
#endif
#if CHARTBOOST_ADS//1.6.1
        enableChartboostAds = true;
#else
        enableChartboostAds = false;
#endif

#if FACEBOOK
        FacebookManager fbManager = gameObject.AddComponent <FacebookManager>();
        fbManager.facebookButton = facebookButton;
#endif


#if GOOGLE_MOBILE_ADS
        enableGoogleMobileAds = true;          //1.6.1
#if UNITY_ANDROID
        MobileAds.Initialize(admobUIDAndroid); //2.1.6
        interstitial = new InterstitialAd(admobUIDAndroid);
#elif UNITY_IOS
        MobileAds.Initialize(admobUIDIOS);//2.1.6
        interstitial = new InterstitialAd(admobUIDIOS);
#else
        MobileAds.Initialize(admobUIDAndroid);//2.1.6
        interstitial = new InterstitialAd(admobUIDAndroid);
#endif

        // Create an empty ad request.
        requestAdmob = new AdRequest.Builder().Build();
        // Load the interstitial with the request.
        interstitial.LoadAd(requestAdmob);
        interstitial.OnAdLoaded       += HandleInterstitialLoaded;
        interstitial.OnAdFailedToLoad += HandleInterstitialFailedToLoad;
#else
        enableGoogleMobileAds = false;//1.6.1
#endif
        Transform canvas = GameObject.Find("CanvasGlobal").transform;
        foreach (Transform item in canvas)
        {
            if (item.gameObject.name != "FPS")
            {
                item.gameObject.SetActive(false);
            }
        }
    }
 void Awake()
 {
     DontDestroyOnLoad(this.gameObject);
     gameInfo = GameObject.Find("InitHolder").GetComponent<InitScript>();
 }
Example #26
0
    // Use this for initialization
    void Awake()
    {
        if (Application.platform == RuntimePlatform.WindowsEditor)
        {
            Application.targetFrameRate = 60;
            //	PlayerPrefs.DeleteAll();
            //	Hat = true;
            //	InfinityLife = true;
            //	StickyStars = true;
            tutPassed = true;
//			RestScores();
        }
        Beatedfriends = new List <string>();
        Beatedfriends.Clear();

        //		if( !InitScript.WasInApp)
//			ChartboostAd.Instance().LoadInterstitialAd(false);
        RestLifeTimer = PlayerPrefs.GetFloat("RestLifeTimer");
        DateOfExit    = PlayerPrefs.GetString("DateOfExit");
        if (PlayerPrefs.GetInt("WasInApp") == 1)
        {
            InitScript.WasInApp = true;
        }

        if (PlayerPrefs.GetInt("InfinityLife") == 1)
        {
            InitScript.InfinityLife = true;
        }

        if (PlayerPrefs.GetInt("StickyStars") == 1)
        {
            InitScript.StickyStars = true;
        }

        Inctance = this;
        Gems     = PlayerPrefs.GetInt("Gems");
//		if(PlayerPrefs.GetInt("tutPassed") == 1)
//			tutPassed = true;

        if (PlayerPrefs.GetInt("Lauched") == 0)            //First lauching
        {
            FirstTime = true;
            Gems      = 10;
            PlayerPrefs.SetInt("Gems", Gems);
            PlayerPrefs.SetInt("Lauched", 1);
            PlayerPrefs.Save();
        }


        //GameObject.Find("SkillsCanvas").gameObject.SetActive(false);
        //this.Skills(false);

        // see if we've got game music still playing
        GameObject gameMusic = GameObject.Find("Music");

//		if (gameMusic) {
//			// kill game music
//			Destroy(gameMusic);
//		}
        // make sure we survive going to different scenes
        //	DontDestroyOnLoad(gameMusic);

        Invoke("DelayStart", 0.001f);
    }
 // Use this for initialization
 void Awake()
 {
     ocupies = new ObstacleOccupation(laneswide, lanesHigh, lanesDeep);
     statHandler = GameObject.Find("InitHolder").GetComponent<InitScript>();
 }