public FightObject createFightObject(FightEntity entity) { GameObject go = null; FightObject fightObject = null; switch (entity.type) { case ConfigConstant.ENTITY_LOOP_BEAN: // go = ResFactory.instance.getBean(((LoopBeanEntity)entity).itemType); fightObject = go.GetComponent <Bean>(); break; case ConfigConstant.ENTITY_PLAYER: if (((PlayerEntity)entity).uid == this.uid) { go = ResFactory.createObject <GameObject>(ResFactory.instance.player); fightObject = go.AddComponent <PlayerSelf>(); } else { go = ResFactory.createObject <GameObject>(ResFactory.instance.player); fightObject = go.AddComponent <Enemy>(); } break; case ConfigConstant.ENTITY_BULLET: fightObject = ResFactory.getBullet(entity.data["resId"].ToString(), this); break; case ConfigConstant.ENTITY_PRICE_BEAN: go = ResFactory.instance.getBean(((PriceBeanEntity)entity).itemType); fightObject = go.GetComponent <Bean>(); break; case ConfigConstant.ENTITY_CALL: go = ResFactory.createObject <GameObject>(ResFactory.instance.call); fightObject = go.GetComponent <CallView>(); break; case ConfigConstant.ENTITY_BARRIER: go = ResFactory.loadPrefab(entity.data["resId"].ToString()); go = ResFactory.createObject <GameObject>(go); fightObject = go.GetComponent <Barrier>(); break; case ConfigConstant.ENTITY_RADISH: go = ResFactory.loadPrefab("radish"); go = ResFactory.createObject <GameObject>(go); fightObject = go.AddComponent <Radish>(); break; } entity.viewData.view = entity.view = fightObject; fightObject.fightEntity = entity; return(fightObject); }
public void init(GameObject parent, int index) { this.go = ResFactory.loadPrefab("scoreRankItem"); this.go = ResFactory.createObject <GameObject>(this.go); this.bg = this.go.transform.FindChild("bgImage").GetComponent <Image>(); this.nameText = this.go.transform.FindChild("nameText").GetComponent <Text>(); this.scoreText = this.go.transform.FindChild("scoreText").GetComponent <Text>(); this.indexText = this.go.transform.FindChild("indexText").GetComponent <Text>(); this.go.transform.SetParent(parent.transform, false); }
public void playVoice(string voiceName, float delay = 0f) { AudioClip audioClip = ResFactory.loadVoiceClip(voiceName); GameObject go = ResFactory.loadPrefab("audio"); go = ResFactory.createObject <GameObject>(go); go.name = voiceName; AudioSource audioSource = go.GetComponent <AudioSource>(); audioSource.clip = audioClip; audioSource.PlayDelayed(delay); ResFactory.Destroy(go, audioClip.length + delay); go.transform.SetParent(this.audioController.transform); }
void Awake() { GameObject go = ResFactory.loadPrefab("card"); for (int i = 0, len = this._initCards.Length; i < len; i++) { Card card = ResFactory.createObject <GameObject>(go).GetComponent <Card>(); card.index = i; this._initCards[i] = card; card.transform.SetParent(Tools.FindChild2("bottomLayer", this.gameObject).transform, false); card.transform.localPosition = new Vector3(230 + i * 130, 75, 0); } this.testBtnChange.onClick.AddListener(() => { this.testBtn.SetActive(!this.testBtn.activeSelf); }); this.voiceBtn.onClick.AddListener(() => { this.testCanvas.SetActive(!this.testCanvas.activeSelf); }); }
protected override TeamBall createBall() { return(ResFactory.createObject <GameObject>(ResFactory.loadPrefab("radishBall")).GetComponent <RadishBall>()); }