internal void SetMainObject(MainObjectData mObjectData, float radius, GameMode gMode) { if (mObjectData == null) { return; } if (!Mainobject) { Mainobject = MainObject.Create(this, mObjectData, gMode == GameMode.Play, radius, true); // Debug.Log("set mo : " +Mainobject.ToString() ); if (gMode == GameMode.Play) { if (Mainobject == null && IsTopObjectGridcell) { if (coll2D) { coll2D.enabled = true; // use as target for shooting } } if (Mainobject != null && IsTopObjectGridcell) { if (coll2D) { coll2D.enabled = false; } } } else { if (coll2D) { coll2D.enabled = true; } } } else { Mainobject.SetData(mObjectData); } // Debug.Log("Set main object: " + ToString()); }
internal void SetData(MainObjectData mData, Booster booster, Material mat, int sortingOrder, bool enableCollider, Action onClick) { MData = mData; this.booster = booster; BoosterObjectData BData = (booster != null)? booster.bData : null; SpriteRenderer shootBubbleSR = GetComponent <SpriteRenderer>(); shootBubbleSR.material = mat; shootBubbleSR.sprite = (MData != null) ? MData.ObjectImage : BData.ObjectImage; sprite = shootBubbleSR.sprite; shootBubbleSR.sortingOrder = sortingOrder; CircleCollider2D cC = GetComponent <CircleCollider2D>(); cC.enabled = enableCollider; cC.isTrigger = true; // avoid bouncing this.PointerDownDel += (tpe) => { if (onClick != null) { onClick(); } }; }
/// <summary> /// Create new MainObject for gridcell /// </summary> /// <param name="parent"></param> /// <param name="mData"></param> /// <param name="addCollider"></param> /// <param name="radius"></param> /// <param name="isTrigger"></param> /// <returns></returns> public static MainObject Create(GridCell parent, MainObjectData mData, bool addCollider, float radius, bool isTrigger) { if (!parent || mData == null) { return(null); } SpriteRenderer sR = Creator.CreateSpriteAtPosition(parent.transform, mData.ObjectImage, parent.transform.position); GameObject gO = sR.gameObject; MainObject Mainobject = gO.AddComponent <MainObject>(); #if UNITY_EDITOR gO.name = "main " + parent.ToString(); #endif Mainobject.Init(parent.Row, parent.Column, parent); if (addCollider) { CircleCollider2D cC = Mainobject.gameObject.GetOrAddComponent <CircleCollider2D>(); cC.radius = radius; cC.isTrigger = isTrigger; } Mainobject.SetData(mData); return(Mainobject); }
public void SetMainObject(GridCell gCell, MainObjectData mData) { gCell.SetMainObject(mData, BubleRadius, gMode); }
/// <summary> /// /// </summary> /// <param name="mData"></param> public void SetData(MainObjectData mData) { MOData = mData; baseObjectData = mData; SetToFront(false); }