void M8.IPoolSpawn.OnSpawned(M8.GenericParams parms) { if (parms != null) { if (parms.ContainsKey(parmDir)) { mDir = parms.GetValue <Vector2>(parmDir); } if (parms.ContainsKey(parmForce)) { float f = parms.GetValue <float>(parmForce); mForce = mDir * f; } if (parms.ContainsKey(parmDuration)) { mDuration = parms.GetValue <float>(parmDuration); } else { mDuration = defaultDuration; } } }
void M8.IModalPush.Push(M8.GenericParams parms) { //apply outcome CollectController collectCtrl = null; var go = GameObject.FindGameObjectWithTag(collectControllerTag); if (go) { collectCtrl = go.GetComponent <CollectController>(); } if (!collectCtrl) { Debug.LogWarning("Collect Controller Not Found!"); return; } M8.SoundPlaylist.instance.Play(soundPlay, false); collectCtrl.ApplyOutcome(); //setup display of collections var collects = collectCtrl.collectList; infoList.Init(collects, null); }
void M8.IModalPush.Push(M8.GenericParams parms) { mDescTextRef = null; mIsDescSpoken = false; mCallback = null; if (parms != null) { if (parms.ContainsKey(parmTitleTextRef)) { if (titleText) { titleText.text = M8.Localize.Get(parms.GetValue <string>(parmTitleTextRef)); } } if (parms.ContainsKey(parmDescTextRef)) { mDescTextRef = parms.GetValue <string>(parmDescTextRef); if (descText) { descText.text = M8.Localize.Get(mDescTextRef); } } if (parms.ContainsKey(parmCallback)) { mCallback = parms.GetValue <System.Action <bool> >(parmCallback); } } }
void M8.IModalPush.Push(M8.GenericParams parms) { if (button) { button.interactable = allowRestart; } }
public GameObject Spawn(string templateName, Vector2 position, float rotate, M8.GenericParams parms) { GameObject spawnGO = null; TemplateInfo template = null; for (int i = 0; i < templates.Length; i++) { if (templates[i].name == templateName) { template = templates[i]; break; } } if (template != null) { mSpawnParms.Clear(); mSpawnParms[JellySpriteSpawnController.parmPosition] = position; mSpawnParms[JellySpriteSpawnController.parmRotation] = rotate; mSpawnParms.Merge(parms, true); var spawn = mPool.Spawn(templateName, templateName, null, mSpawnParms); spawnGO = spawn.gameObject; } else { Debug.LogWarning("Template does not exists: " + templateName); } return(spawnGO); }
void M8.IPoolSpawn.OnSpawned(M8.GenericParams parms) { if (parms != null) { if (parms.ContainsKey(parmDir)) { mDir = parms.GetValue <Vector2>(parmDir); } else { mDir = dir; } if (parms.ContainsKey(parmSpeed)) { mInitSpeed = parms.GetValue <float>(parmSpeed); } else { mInitSpeed = initialSpeed; } if (parms.ContainsKey(parmAccel)) { mAccel = parms.GetValue <float>(parmAccel); } else { mAccel = accel; } } }
void M8.IModalPush.Push(M8.GenericParams parms) { ResetDisplay(); int ind = -1; if (parms != null) { if (parms.ContainsKey(parmTitle)) { titleText.text = parms.GetValue <string>(parmTitle); } if (parms.ContainsKey(parmIndex)) { ind = parms.GetValue <int>(parmIndex); } } if (ind != -1 && ind < categoryGroups.Length) { var cat = categoryGroups[ind]; for (int i = 0; i < cat.categories.Length; i++) { var key = cat.categories[i]; if (mCategories.ContainsKey(key)) { mCategories[key].SetActive(true); } } } }
void M8.IModalPush.Push(M8.GenericParams parms) { ClearItems(); mFlagDataIndex = -1; mCurIndex = 0; mSearchKeywordData = null; mKeywordResultIndex = 0; if (parms != null) { if (parms.ContainsKey(parmSearchKeywordData)) { mSearchKeywordData = parms.GetValue <SearchKeywordData>(parmSearchKeywordData); } if (parms.ContainsKey(parmSearchKeywordResultIndex)) { mKeywordResultIndex = parms.GetValue <int>(parmSearchKeywordResultIndex); } } //grab which item to use FlagData itm = null; if (mSearchKeywordData != null) { titleText.text = string.Format(M8.Localize.Get(titleTextRef), mSearchKeywordData.results[mKeywordResultIndex].text); for (int i = 0; i < items.Length; i++) { var _itm = items[i]; if (_itm.sourceKeywordData == mSearchKeywordData && _itm.sourceKeywordResultIndex == mKeywordResultIndex) { itm = _itm; mFlagDataIndex = i; break; } } } else { } if (itm != null) { //fill list var dats = itm.data; for (int i = 0; i < dats.Length; i++) { AllocateItem(itm, i); } UpdateSelectFlag(); } scroller.normalizedPosition = new Vector2(0f, 1f); }
void M8.IPoolSpawn.OnSpawned(M8.GenericParams parms) { mCellIndex = new GridCell { b = 0, row = 0, col = 0 }; _cellSize = new GridCell { b = 1, row = 1, col = 1 }; if (parms != null) { if (parms.ContainsKey(parmData)) { _data = parms.GetValue <GridEntityData>(parmData); } if (parms.ContainsKey(parmCellIndex)) { mCellIndex = parms.GetValue <GridCell>(parmCellIndex); } if (parms.ContainsKey(parmCellSize)) { _cellSize = parms.GetValue <GridCell>(parmCellSize); } } container.AddEntity(this); RefreshPosition(); RefreshBounds(); }
void IPush.Push(M8.GenericParams parms) { resultProceedButtonGO.SetActive(false); giveUpButton.interactable = true; ButtonOptions.instance.showGiveUp = false; }
void M8.IModalPush.Push(M8.GenericParams parms) { mIsInspection = false; if (parms != null) { if (parms.ContainsKey(parmIsInspection)) { mIsInspection = parms.GetValue <bool>(parmIsInspection); } } scroller.normalizedPosition = new Vector2(0f, 1f); mItems[mItemFlaggableInd].isFlagged = ipFlaggedItem.isFlagged; if (mIsInspection) { mCurIndex = 0; UpdateSelected(); inspectSelectable.gameObject.SetActive(true); } else { inspectSelectable.gameObject.SetActive(false); } }
void M8.IModalPush.Push(M8.GenericParams parms) { titleText.text = ""; mCallback = null; mDelay = 0f; if (parms != null) { if (parms.ContainsKey(parmDelay)) { mDelay = parms.GetValue <float>(parmDelay); } if (parms.ContainsKey(parmTitleString)) { titleText.text = parms.GetValue <string>(parmTitleString); } if (parms.ContainsKey(parmCallback)) { mCallback = parms.GetValue <System.Action>(parmCallback); } } SetProgress(0f); }
void M8.IModalPush.Push(M8.GenericParams parms) { bool closeShow = false; int index = -1; if (parms != null) { if (parms.ContainsKey(parmCycleIndex)) { index = parms.GetValue <int>(parmCycleIndex); } if (parms.ContainsKey(parmShowClose)) { closeShow = parms.GetValue <bool>(parmShowClose); } } for (int i = 0; i < groups.Length; i++) { groups[i].SetActive(i == index); } if (backGO) { backGO.SetActive(closeShow); } if (closeGO) { closeGO.SetActive(closeShow); } }
void M8.UIModal.Interface.IPush.Push(M8.GenericParams parms) { mTextRef = titleDefaultTextRef; string text = ""; if (parms != null) { if (parms.ContainsKey(parmText)) { mTextRef = null; text = parms.GetValue <string>(parmText); } else if (parms.ContainsKey(parmTextRef)) { mTextRef = parms.GetValue <string>(parmTextRef); } } if (titleLabel) { if (!string.IsNullOrEmpty(mTextRef)) { titleLabel.text = M8.Localize.Get(mTextRef); } else { titleLabel.text = text; } } }
void M8.IModalPush.Push(M8.GenericParams parms) { //allocate album if (mImages == null) { mImages = new PhotoAlbumItemWidget[GameData.instance.captureCount]; for (int i = 0; i < mImages.Length; i++) { var img = Instantiate(templateItem); img.transform.SetParent(contentRoot, false); img.Apply(null); img.gameObject.SetActive(true); mImages[i] = img; } } //setup captured images var captures = GameData.instance.captureInfos; for (int i = 0; i < captures.Length; i++) { mImages[i].Apply(captures[i].texture); } //compute and update capture score GameData.instance.UpdateCaptureScore(); percentText.text = Mathf.RoundToInt(GameData.instance.capturePercent * 100f).ToString() + '%'; scoreText.text = GameData.instance.captureScore.ToString(); }
void Update() { var activeCount = mPlantActives.Count; if (activeCount > mCurCount) { int count = activeCount - mCurCount; for (int i = 0; i < count; i++) { var pdc = mPlantActives.RemoveLast(); mSpawnPts.Add(pdc.transform.parent); pdc.Release(); } } else if (activeCount < mCurCount) { int count = mCurCount - activeCount; for (int i = 0; i < count; i++) { int spawnToInd = Random.Range(0, mSpawnPts.Count); var spawnToTrans = mSpawnPts[spawnToInd]; mSpawnPts.RemoveAt(spawnToInd); var parms = new M8.GenericParams(); parms[Plant.parmSourceSun] = sourceSun; var pdc = mPoolCtrl.Spawn(template.name, "plant", spawnToTrans, parms); pdc.transform.localPosition = Vector3.zero; pdc.transform.localScale = Vector3.one; mPlantActives.Add(pdc); } } }
public override void Push(M8.GenericParams parms) { base.Push(parms); var parmPairs = parms.GetValue <PairRef[]>(parmPairRefs); List <PairRef> parsedRefs = new List <PairRef>(); for (int i = 0; i < parmPairs.Length; i++) { var parsed = Utility.GrabLocalizeGroup(parmPairs[i].stringRef); for (int j = 0; j < parsed.Length; j++) { var newRef = new PairRef() { sprite = parmPairs[i].sprite, stringRef = parsed[j] }; parsedRefs.Add(newRef); } } mRefs = parsedRefs.ToArray(); mCurRefInd = 0; imageDisplay.gameObject.SetActive(false); mIsImageShown = false; }
void M8.IModalPush.Push(M8.GenericParams parms) { if (parms != null) { if (parms.ContainsKey(parmPortraitSprite)) { SetupPortraitTextContent(parms.GetValue <Sprite>(parmPortraitSprite), parms.GetValue <string>(parmNameTextRef), parms.GetValue <string>(parmDialogTextRef)); } else { SetupTextContent(parms.GetValue <string>(parmNameTextRef), parms.GetValue <string>(parmDialogTextRef)); } mNextCallback = parms.GetValue <System.Action>(parmNextCallback); } if (textProcessActiveGO) { textProcessActiveGO.SetActive(false); } if (textProcessFinishGO) { textProcessFinishGO.SetActive(false); } mIsNextProcessed = false; }
public GridEntity Spawn(GridCell cell, GridCell cellSize) { GridEntity ret = null; //ensure we can spawn on given cell info var container = GridEditController.instance.entityContainer; if (container.IsPlaceable(cell, cellSize, null)) { if (!mPool) { mPool = M8.PoolController.CreatePool(poolGroup); mPool.AddType(template, poolCapacity, poolCapacity); } if (mSpawnParms == null) { mSpawnParms = new M8.GenericParams(); } mSpawnParms[GridEntity.parmData] = this; mSpawnParms[GridEntity.parmCellIndex] = cell; mSpawnParms[GridEntity.parmCellSize] = cellSize; ret = mPool.Spawn <GridEntity>(template.name, name, container.root, mSpawnParms); } return(ret); }
void M8.IModalPush.Push(M8.GenericParams parms) { //compute max score mScoreMax = 0; for (int i = 0; i < LevelController.instance.shapes.Length; i++) { mScoreMax += GameData.instance.scoreShape; } //score mScore = 0; for (int i = 0; i < LevelController.instance.shapesCollected.Count; i++) { mScore += LevelController.instance.shapesCollected[i].score; } scoreCounter.SetCountImmediate(0); scoreCounter.count = mScore; var rank = GameData.instance.GetRank(Mathf.Clamp01((float)mScore / mScoreMax)); rankText.text = rank.text; rankText.color = rank.color; }
protected override void OnSpawned(M8.GenericParams parms) { //populate data/state for ai, player control, etc. int toState = (int)EntityState.Normal; Transform toAnchor = null; if (parms != null) { if (parms.ContainsKey(Params.state)) { toState = parms.GetValue <int>(Params.state); } if (parms.ContainsKey(Params.anchor)) { toAnchor = parms.GetValue <Transform>(Params.anchor); } } //start ai, player control, etc anchor = toAnchor; state = toState; if (mStats.data.registerAsEnemy) { MissionController.instance.Signal(MissionController.SignalType.EnemyRegister, this); } }
void IPush.Push(M8.GenericParams parms) { if (!mPaused) { mPaused = true; M8.SceneManager.instance.Pause(); } bool showGiveUp = false; if (parms != null) { if (parms.ContainsKey(parmShowGiveUp)) { showGiveUp = parms.GetValue <bool>(parmShowGiveUp); } } //show give up? if (showGiveUp) { giveUpGO.SetActive(true); giveUpButton.interactable = true; } else { giveUpGO.SetActive(false); } }
public void Spawn() { //shouldn't call this if there's already a spawn, so release the previous if (mSpawned) { if (preSpawned) { preSpawned.transform.position = transform.position; preSpawned.gameObject.SetActive(true); } else if (mSpawned.stats.isAlive) { mSpawned.Release(); } } var parms = new M8.GenericParams(); parms[Params.state] = (int)EntityState.Control; parms[Params.anchor] = transform; if (preSpawned) { mSpawned = preSpawned; mSpawned.Spawn(parms); //manually "spawn" } else { mSpawned = M8.PoolController.SpawnFromGroup <EntityCommon>(poolGroup, poolSpawnRef, poolSpawnRef, null, transform.position, parms); if (mSpawned) { mSpawned.releaseCallback += OnSpawnedReleased; } } }
void M8.IModalPush.Push(M8.GenericParams parms) { ClearItems(); //go through items and check which are flagged for (int i = 0; i < itemData.Length; i++) { var itm = itemData[i]; if (itm.isFlagged) { AllocateItem(i, itm); } } scroller.normalizedPosition = new Vector2(0f, 1f); if (mItemActive.Count > 0) { mCurIndex = mItemActive[0].index; checkSelectable.interactable = true; mItemActive[0].isSelected = true; } else { checkSelectable.interactable = false; } }
void M8.IPoolSpawn.OnSpawned(M8.GenericParams parms) { GameMapController.instance.paletteUpdateCallback += OnPaletteUpdate; GameMapController.instance.blockSelectedChangeCallback += OnGameBlockSelectChange; GameMapController.instance.modeChangeCallback += OnGameChangeMode; BlockInfo blockInf = parms.GetValue <BlockInfo>(paramBlockInfo); bool showIntro = parms.GetValue <bool>(paramShowIntro); //setup data mBlockName = blockInf.name; //setup state UpdateInteractible(); //setup display blockNameText.text = M8.Localize.Get(blockInf.nameDisplayRef); blockImage.sprite = blockInf.icon; UpdateCount(); ApplySelected(isSelected); //show intro? if (showIntro) { //animation } if (disableGO) { disableGO.SetActive(false); } }
void M8.IModalPush.Push(M8.GenericParams parms) { switch (mode) { case Mode.None: mSelect = null; break; case Mode.Previous: var es = EventSystem.current; if (es) { mSelect = es.currentSelectedGameObject; } else { mSelect = null; } break; case Mode.Param: if (parms != null && parms.ContainsKey(parmSelectGO)) { mSelect = parms.GetValue <GameObject>(parmSelectGO); } else { mSelect = null; } break; } }
void M8.IModalPush.Push(M8.GenericParams parms) { //check if we need to fill in new items var activityLogs = GameData.instance.activityLogs; //NOTE: assume we only add more activity logs if (mItemWidgets.Count < activityLogs.Count) { int count = activityLogs.Count - mItemWidgets.Count; for (int i = 0; i < count; i++) { int logInd = mItemWidgets.Count; var activityLog = activityLogs[logInd]; //add new item at the top var newItemWidget = Instantiate(itemTemplate); newItemWidget.transform.SetParent(contentRoot, false); newItemWidget.transform.SetAsFirstSibling(); newItemWidget.Apply(activityLog); newItemWidget.gameObject.SetActive(true); mItemWidgets.Add(newItemWidget); } } scroller.normalizedPosition = new Vector2(0f, 1f); }
void M8.UIModal.Interface.IPush.Push(M8.GenericParams parms) { mIndex = 0; if (parms != null) { mTransfer = parms.GetValue <TracerGraphControl>(parmTransferTraceGraph); mIndex = parms.GetValue <int>(parmIndex); } //apply index for (int i = 0; i < counts.Length; i++) { var count = counts[i]; if (i < mIndex) { count.animator.Play(count.takeFilled); } else if (i >= mIndex) { count.animator.Play(count.takeEmpty); } } //apply transfer if (mTransfer) { mTransferLastParent = mTransfer.transform.parent; mTransfer.transform.SetParent(transferRoot, false); mTransfer.transform.localPosition = Vector3.zero; mTransfer.transform.localScale = Vector3.one; } }
protected override void OnSpawned(M8.GenericParams parms) { //populate data/state for ai, player control, etc. //start ai, player control, etc state = (int)EntityState.Normal; }
public override void Push(M8.GenericParams parms) { base.Push(parms); mRefs = parms.GetValue <PairRef[]>(parmPairRefs); var parmPairs = parms.GetValue <PairRef[]>(parmPairRefs); List <PairRef> parsedRefs = new List <PairRef>(); for (int i = 0; i < parmPairs.Length; i++) { var parsed = Utility.GrabLocalizeGroup(parmPairs[i].stringRef); for (int j = 0; j < parsed.Length; j++) { var newRef = new PairRef() { compositeName = parmPairs[i].compositeName, clear = parmPairs[i].clear, stringRef = parsed[j] }; parsedRefs.Add(newRef); } } mRefs = parsedRefs.ToArray(); mCurRefInd = 0; }