public void OnDead() { List <ItemDropInfo> r = new List <ItemDropInfo>(); for (int i = 0; i < DropCount; i++) { List <ItemDropInfo> pick = new List <ItemDropInfo>(); foreach (var ii in DropInfos) { if (ARandom.Get(ii.drop_chance)) { pick.Add(ii); } } if (pick.Count == 0) { continue; } r.Add(pick[Random.Range(0, pick.Count)]); } foreach (var i in r) { ItemDB.Inst.SpawnDroppedItem( i.item, transform.position, Random.Range(i.DropCount.min, i.DropCount.max) ).GetComponent <Rigidbody2D>().AddForce(Random.insideUnitCircle * Random.Range(100f, 200f)); } }
Vector2 calc_spawn_pos(int[] chance_of, float y) { var r = Random.Range(0, chance_of.Length); var t = r + chance_of[r] * (ARandom.Get(50) ? -1 : 1); t = t < 0 ? chance_of.Length - Mathf.Abs(t) : t; t %= chance_of.Length; return(new Vector2(r, y)); }
public bool IsFindCeiling() { HangTask.mCeilingCoolTimeT += Time.deltaTime; if (!HangTask.IsCeilingNearOf()) { } else if (HangTask.FindCeiling) { HangTask.IsFollowEndToCeiling = HangTask.IsCeilingNear(); return(true); } if ((FindCeilingT += Time.deltaTime) < HangTask.CeilingCoolTime) { return(false); } // 벽에 매달리지 않는다. // 벽을 검색 하지 않는 타이머를 설정한 뒤 빠져나온다. if (bUseTimer && !ARandom.Get(HangTask.CeilingPercentage)) { FindCeilingT = 0; return(false); } else { var Tr = Detect.GetHitTrOrNull(transform.position, Vector2.up, HangTask.mCeilingDetectRange, GM.SoildGroundLayer); if (Tr) { HangTask.MyCeiling = Tr; // 발견한 천장이 이미 누가 매달려 있는 벽이라면? if (FlowerBat_Task_Hang.HangWalls.Contains(HangTask.MyCeiling.gameObject)) { bUseTimer = false; return(false); } //찾은 천장을 목적지로 설정. HangTask.mCeilingPos = Tr.position; //천장을 찾았다. HangTask.FindCeiling = true; bUseTimer = true; } else { bUseTimer = false; return(false); } FlowerBat_Task_Hang.HangWalls.Add(Tr.gameObject); HangTask.IsFollowEndToCeiling = HangTask.IsCeilingNear(); return(true); } }
public void Spawn(Vector2 pos) { var gv = GridView.Inst[GM.CurMapName][1]; while (gv.GetNodeAtWorldPostiton(pos).isObstacle) { pos.x += 1; } table.for_each(x => ARandom.Get(x.chance).IF(() => Instantiate(x.mob, pos, Quaternion.identity))); }
//================================================================= // ## Mob_WeepingMist :: Hurt //================================================================= public override void OnHurt() { if (mHitImmunity) { return; } if (ARandom.Get(RandRangeOfTeleport)) { OnTeleportPre(); } else { base.OnHurt(); } //base.OnHurt(); //OnTeleportPre(); }
public bool MoveRandom() { if (!m_groundDetectionData.isGrounded) { return(false); } m_MoveData.State = MobMoveData.eState.Move; m_CurAniST = eMobAniST.Walk; ATimer.Tick(this); if (!m_bYMoveCoolTime && !m_bJumpStart) { m_bYMoveCoolTime = ARandom.Get(70) ? true : ARandom.Get(50) ? Jump() : Fall(); m_bYMoveCoolTime = true; ATimer.Set("JumpFall" + GetInstanceID(), m_MoveData.CoolTime, () => { m_bYMoveCoolTime = false; }); } return(true); }