private void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.tag == "Monster" && atk) { if (haveKey) { MonsterMove mob = other.gameObject.GetComponent <MonsterMove>(); Animator newnim = mob.blood.GetComponent <Animator>(); newnim.SetBool("Blood", true); mob.Die(); } } if (other.gameObject.tag == "Ground") { jumpcount = 0; } if (other.gameObject.tag == "GASHI") { Die(); } if (other.gameObject.tag == "DOOR") { if (haveKey == true) { BoxCollider2D box; box = other.gameObject.GetComponent <BoxCollider2D>(); box.enabled = false; Animator sanimator = other.gameObject.GetComponent <Animator>(); sanimator.SetBool("OPEN", true); } } }
public void Destroy() { GameObject.Destroy(go); go = null; moveController = null; collider2D = null; }
void Start() { anim = transform.GetComponent <Animator>(); move = transform.GetComponent <MonsterMove>(); player = GameObject.FindGameObjectWithTag("Player"); switch (monsterid) { case 0: touchdamage = 5; monsterhp = 25; move.speed = 5f; mentaldamage = 0.9f; attackrange = 2; break; case 1: touchdamage = 2; monsterhp = 12; move.speed = 5f; mentaldamage = 0.45f; attackrange = 2; break; case 2: touchdamage = 3; monsterhp = 22; move.speed = 0.7f; mentaldamage = 0f; attackrange = 8; break; } }
protected void InitMonstInfo() { //MonsterInfo.MonsterCharInfo monsterCharInfo; m_monsterInfo = GetComponent <MonsterInfo>(); m_monsterMove = GetComponent <MonsterMove>(); m_monsterMove.SetSpeed(m_monsterInfo.speed); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { mm = animator.GetComponent <MonsterMove>(); nmAgent = animator.GetComponent <NavMeshAgent>(); nmAgent.speed = chaseSpeed; nmAgent.isStopped = false; mm.GetComponent <Rigidbody>().isKinematic = true; }
void CheckMoveStateStart() { if (!isMoving) { MonsterMove.Invoke(); isMoving = true; } }
// Start is called before the first frame update void Awake() { r2d = GetComponent <Rigidbody2D>(); sr = GetComponent <SpriteRenderer>(); at = GetComponent <Animator>(); c2d = GetComponent <CapsuleCollider2D>(); audioSource = GetComponent <AudioSource>(); mMove = GetComponent <MonsterMove>(); }
public void 相性倍率のダメージは切り捨てられる() { var fireMove2 = new MonsterMove(new MonsterMovePower(3), Type.Fire); var param = new MonsterParams(prop, Type.Water); var dmg = DamageCalculator.Calculate(param, fireMove2); // 1.5 が 切り捨てで 1 になる Assert.That(dmg.value, Is.EqualTo(1)); }
private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.tag == "Enermy") { emgo = null; Monster = null; em_stat = null; animator = null; } }
public void Stop() { MoveSpline move_spline = unit.moveSpline; // No need to stop if we are not moving if (move_spline.Finalized()) { return; } bool transport = !unit.GetTransGUID().IsEmpty(); Vector4 loc = new Vector4(); if (move_spline.onTransport == transport) { loc = move_spline.ComputePosition(); } else { Position pos; if (!transport) { pos = unit; } else { pos = unit.m_movementInfo.transport.pos; } loc.X = pos.GetPositionX(); loc.Y = pos.GetPositionY(); loc.Z = pos.GetPositionZ(); loc.W = unit.GetOrientation(); } args.flags.Flags = SplineFlag.Done; unit.m_movementInfo.RemoveMovementFlag(MovementFlag.Forward); move_spline.onTransport = transport; move_spline.Initialize(args); MonsterMove packet = new MonsterMove(); packet.MoverGUID = unit.GetGUID(); packet.Pos = new Vector3(loc.X, loc.Y, loc.Z); packet.SplineData.StopDistanceTolerance = 2; packet.SplineData.ID = move_spline.GetId(); if (transport) { packet.SplineData.Move.TransportGUID = unit.GetTransGUID(); packet.SplineData.Move.VehicleSeat = unit.GetTransSeat(); } unit.SendMessageToSet(packet, true); }
void OnAttack(Transform monster) { gameManager.stagePoint += 100; rigid.AddForce(Vector2.up * 10, ForceMode2D.Impulse); MonsterMove monsterMove = monster.GetComponent<MonsterMove>(); monsterMove.OnDamaged(); PlaySound("ATTACK"); audioSource.Play(); }
private void OnTriggerEnter2D(Collider2D collider) { Unit unit = collider.gameObject.GetComponent <Unit>(); MonsterMove monsterMove = collider.gameObject.GetComponent <MonsterMove>(); Monster monster = collider.gameObject.GetComponent <Monster>(); if (unit && !monster && !monsterMove) { ResieveDamage(); } }
/// <summary> /// Function which runs when the object is created, and assigns some nessicary references. /// </summary> void Awake() { inst = this; // Setup singleton // Make sure that the reference to the NavMeshAgent is set agent = GetComponent <NavMeshAgent>(); if (agent == null) { Debug.LogError("This script must be attached to an object with a NavMeshAgent attached! Not found on: " + gameObject.name); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Enermy") { emgo = collision.gameObject; emStats = emgo.GetComponent <EmStats>(); Monster = emgo.GetComponent <MonsterMove>(); em_stat = emgo.GetComponent <EmStats>(); animator = emgo.GetComponent <Animator>(); playerstat = GameObject.FindWithTag("Player").GetComponent <PlayerStats>(); } }
public void OnAttack(Transform enermy) { //point gameManager.stagePoint += 100; //reaction force r2d.AddForce(Vector2.up * 10, ForceMode2D.Impulse); //enermy die MonsterMove mMove = enermy.GetComponent <MonsterMove>(); Debug.Log(mMove); mMove.Damaged(); }
private void PlaceMonster(int type, int side, int roadIndex) { if (type < (int)MonsterType.Monster1 || type > (int)MonsterType.Monster3) { return; } if (side != (int)SideType.SideA && side != (int)SideType.SideB) { return; } if (roadIndex < 0 || roadIndex >= this.monsterRoads.Length) { return; } if (type >= this.monsterPrefabs.Length) {//没有对应小怪的资源 return; } //Debug.Log("放置小兵"); GameObject m = Instantiate(this.monsterPrefabs[type]); m.transform.SetParent(this.transform, false); MonsterMove agent = m.AddComponent <MonsterMove>(); Vector3[] roadData = null; if (side == (int)SideType.SideA) { roadData = this._roadDataSet[roadIndex].pathSideA; } else { roadData = this._roadDataSet[roadIndex].pathSideB; } Monster monster = m.AddComponent <Monster>(); monster.Init(type, side, roadData); this._monsters.Add(monster); //创建一个UI血条 UIShowBlood uiBlood = this.UiBloodManager.PlaceUIBloodOnMonster(side); monster.uiBlood = uiBlood; }
void Create() { int odds = Random.Range(0, 100); TYPE type; if (odds < 51) { type = TYPE.SMALL; } else if (odds < 86) { type = TYPE.MEDIUM; } else { type = TYPE.BIG; } //生成怪物 MonsterMove monster = MonsterManage._monstermanage.takemonster(type); if (monster == null) { switch (type) { case TYPE.BIG: temp = Instantiate(BigMonster); break; case TYPE.MEDIUM: temp = Instantiate(MediumMonster); break; case TYPE.SMALL: temp = Instantiate(SmallMonster); break; } monster = temp.GetComponent <MonsterMove>(); } monster.gameObject.SetActive(true); tempVector3 = new Vector3(Random.Range(-2.5f, 2.5f), transform.position.y, transform.position.z); monster.transform.position = tempVector3; //MonsterPoint.position = new Vector3(Random.Range(-2.5f, 2.5f), MonsterPoint.position.y, MonsterPoint.position.z); //monster.transform.position = MonsterPoint.position; //monster.transform.rotation = MonsterPoint.rotation; //monster.transform.parent = MonsterPoint; MonsterManage._monstermanage.addmonster(monster); }
void OnAttack(Transform monster) { //Point gameManager.stagePoint += 1; //Reaction Force rigid.AddForce(Vector2.up * Time.deltaTime * 150, ForceMode2D.Impulse); //Monster Die MonsterMove monsterMove = monster.GetComponent <MonsterMove>(); monsterMove.OnDamaged(); //Sound PlayeSound(audioAttack); }
public Monster(GameObject gameGo, int pathIndex, int monsterId) { go = gameGo; id = monsterId; path = pathIndex; //碰撞体 collider2D = go.GetComponent <Collider2D>(); //移动控制器 moveController = go.GetComponent <MonsterMove>(); if (moveController == null) { moveController = go.AddComponent <MonsterMove>(); } moveController.monster = this; moveController.setSpeed(speed); moveController.setPath(pathIndex); }
void OnTriggerEnter(Collider collider) { MoveController moveController = collider.GetComponent <MoveController>(); if (moveController && moveController.m_IsDie == false) { GamePlay.m_Life = 0; moveController.DoDie(); } MonsterMove monsterMove = collider.GetComponent <MonsterMove>(); if (monsterMove) { Destroy(monsterMove.gameObject); } }
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (0.56 <= stateInfo.normalizedTime && stateInfo.normalizedTime <= 0.80) { hitBox.UpdateHitBox(); if (!entered && stateInfo.normalizedTime >= 0.6f) { MonsterMove mm = animator.GetComponent <MonsterMove>(); var fx = Instantiate(mm.jumpAttackFX, mm.transform.position, Quaternion.identity); Destroy(fx, 2f); AddForceToEny(200f, hitBox.transform.position, 5f, 5f); CameraShake cs = Camera.main.GetComponent <CameraShake>(); cs.enabled = true; cs.StartCoroutine(cs.Shake(0.1f, 0.4f)); entered = !entered; } } }
public void Initialize(Monster mon) { Species = mon.Species; Nickname = mon.Nickname; Type1 = mon.Type1; Type2 = mon.Type2; Level = mon.Level; CurrentHp = mon.CurrentHp; Nature = mon.Nature; BaseStats = mon.BaseStats; EVs = mon.EVs; IVs = mon.IVs; ExperiencePoints = mon.ExperiencePoints; Move1 = mon.Move1; Move2 = mon.Move2; Move3 = mon.Move3; Move4 = mon.Move4; LearnSet = mon.LearnSet; CaptureObject = mon.CaptureObject; Sprite = mon.Sprite; }
void InitMonsterInfo() { MonsterInfo.MonsterCharInfo monsterCharInfo; if (StageDataManager.Inst.nowStage == StageDataManager.StageNameEnum.STAGE_1_1) { monsterCharInfo.level = 1; monsterCharInfo.maxHp = 300; monsterCharInfo.defensive = 10; monsterCharInfo.attack = 70; monsterCharInfo.attackDistance = 2.5f; monsterCharInfo.speed = 5.0f; m_monsterInfo = GetComponent <MonsterInfo>(); m_monsterInfo.SetInfo(monsterCharInfo); } else if (StageDataManager.Inst.nowStage == StageDataManager.StageNameEnum.STAGE_1_2) { monsterCharInfo.level = 1; monsterCharInfo.maxHp = 700; monsterCharInfo.defensive = 10; monsterCharInfo.attack = 150; monsterCharInfo.attackDistance = 2.5f; monsterCharInfo.speed = 5.0f; m_monsterInfo = GetComponent <MonsterInfo>(); m_monsterInfo.SetInfo(monsterCharInfo); } m_monsterMove = GetComponent <MonsterMove>(); m_monsterAttack = GetComponent <MonsterAttack>(); m_animFunction = transform.GetComponentInChildren <AnimFuntion>(); m_receiveDamage = GetComponent <ReceiveDamage>(); m_monsterHpBar = GetComponentInChildren <MonsterHpBar>(); m_monsterPosition = Monster_Position.Monster_Position_Ground; m_monsterMove.SetSpeed(m_monsterInfo.speed); m_bLive = true; }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { mm = animator.GetComponent <MonsterMove>(); }
public int Launch() { MoveSpline move_spline = unit.moveSpline; bool transport = !unit.GetTransGUID().IsEmpty(); Vector4 real_position = new Vector4(); // there is a big chance that current position is unknown if current state is not finalized, need compute it // this also allows calculate spline position and update map position in much greater intervals // Don't compute for transport movement if the unit is in a motion between two transports if (!move_spline.Finalized() && move_spline.onTransport == transport) { real_position = move_spline.ComputePosition(); } else { Position pos; if (!transport) { pos = unit; } else { pos = unit.m_movementInfo.transport.pos; } real_position.X = pos.GetPositionX(); real_position.Y = pos.GetPositionY(); real_position.Z = pos.GetPositionZ(); real_position.W = unit.GetOrientation(); } // should i do the things that user should do? - no. if (args.path.Length == 0) { return(0); } // correct first vertex args.path[0] = new Vector3(real_position.X, real_position.Y, real_position.Z); args.initialOrientation = real_position.W; move_spline.onTransport = !unit.GetTransGUID().IsEmpty(); MovementFlag moveFlags = unit.m_movementInfo.GetMovementFlags(); if (!args.flags.hasFlag(SplineFlag.Backward)) { moveFlags = (moveFlags & ~MovementFlag.Backward) | MovementFlag.Forward; } else { moveFlags = (moveFlags & ~MovementFlag.Forward) | MovementFlag.Backward; } if (Convert.ToBoolean(moveFlags & MovementFlag.Root)) { moveFlags &= ~MovementFlag.MaskMoving; } if (!args.HasVelocity) { // If spline is initialized with SetWalk method it only means we need to select // walk move speed for it but not add walk flag to unit var moveFlagsForSpeed = moveFlags; if (args.walk) { moveFlagsForSpeed |= MovementFlag.Walking; } else { moveFlagsForSpeed &= ~MovementFlag.Walking; } args.velocity = unit.GetSpeed(SelectSpeedType(moveFlagsForSpeed)); } if (!args.Validate(unit)) { return(0); } unit.m_movementInfo.SetMovementFlags(moveFlags); move_spline.Initialize(args); MonsterMove packet = new MonsterMove(); packet.MoverGUID = unit.GetGUID(); packet.Pos = new Vector3(real_position.X, real_position.Y, real_position.Z); packet.InitializeSplineData(move_spline); if (transport) { packet.SplineData.Move.TransportGUID = unit.GetTransGUID(); packet.SplineData.Move.VehicleSeat = unit.GetTransSeat(); } unit.SendMessageToSet(packet, true); return(move_spline.Duration()); }
//回收子弹 public void collection(MonsterMove monster) { monster.gameObject.SetActive(false); lifepool.Remove(monster); diepool.AddLast(monster); }
//添加到生存池 public void addmonster(MonsterMove monster) { lifepool.AddLast(monster); }
public IEnumerator GetWaypoints(Vector2 origin, Vector2 target, MonsterMove monster) { newWp = new List <Vector2Int>(); frontier = new Queue <Vector2Int>(); Vector2Int endPos = Vector2Int.FloorToInt(target); frontier.Enqueue(Vector2Int.FloorToInt(origin)); Dictionary <Vector2Int, Vector2Int> wp = new Dictionary <Vector2Int, Vector2Int>(); wp.Add(Vector2Int.FloorToInt(origin), Vector2Int.FloorToInt(origin)); while (frontier.Count >= 1) { Vector2Int current = frontier.Dequeue(); foreach (Vector2Int next in getNeighbors(Vector2Int.FloorToInt(current))) { //yield return 0; if (!wp.ContainsKey(next)) { frontier.Enqueue(next); //Instantiate(pref, new Vector3(next.x+0.5f, next.y+0.5f, 0f), Quaternion.identity); if (!wp.ContainsKey(next)) { wp.Add(next, current); } if (next == Vector2Int.FloorToInt(target)) { // Debug.Log("Achooo"); frontier.Clear(); break; } } } } Vector2Int newCurrent = Vector2Int.FloorToInt(target); while (newCurrent != Vector2Int.FloorToInt(origin)) { newWp.Add(newCurrent); if (!wp.ContainsKey(newCurrent)) { break; } newCurrent = wp[newCurrent]; } newWp.Reverse(); monster.waypoints.Clear(); foreach (Vector2Int pos in newWp) { monster.waypoints.Enqueue(new Vector3(pos.x + 0.5f, pos.y + 0.5f, 0)); } if (monster.waypoints.Count > 0) { monster.waypoint = monster.waypoints.Dequeue(); } else { monster.waypoint = monster.C.transform.position; } for (int i = 0; i < newWp.Count - 1; i++) { Vector3 ori = new Vector3(newWp[i].x + 0.5f, newWp[i].y + 0.5f, 0); Vector3 dest = new Vector3(newWp[i + 1].x + 0.5f, newWp[i + 1].y + 0.5f, 0); Debug.DrawLine(ori, dest, Color.red, 3f); } yield return(0); }
protected override void Init() { base.Init(); root = new BTPrioritySelector(); // 根节点首先是一个选择器 // 转移条件 MonsterCheckPlayerInRange playerInRange = new MonsterCheckPlayerInRange(checkPlayerRange, PLAYER_NAME); MonsterCheckPlayerInRange playerNotInRange = new MonsterCheckPlayerInRange(checkPlayerRange, PLAYER_NAME, true); // 行为节点 move = new MonsterMove(DESTINATION, moveSpeed); MonsterFindToTargetDestination findToTargetDestination = new MonsterFindToTargetDestination(PLAYER_NAME, PLAYERLOCATION, DESTINATION, ATKdistance); MonsterWait monsterWait = new MonsterWait(); // 怪兽攻击 MonsterAttack monsterAttack; if (myMonsterType == MonsterType.LongDistanceAttack) { monsterAttack = new MonsterLongDistanceAttacks(longDistanceATK); } else if (myMonsterType == MonsterType.MeleeAttack) { monsterAttack = new MonsterMeleeAttack(meleeATK); } else { monsterAttack = new MonsterAttack(meleeATK); // 先暂时为近战的攻击力 } MonsterRandomMoveDistance randomMoveDistance = new MonsterRandomMoveDistance(DESTINATION, moveX, moveZ); MonsterRotateToTarget monsterMoveRotate = new MonsterRotateToTarget(DESTINATION); MonsterRotateToTarget attackRotate = new MonsterRotateToTarget(PLAYERLOCATION); // 攻击 BTSequence attack = new BTSequence(playerInRange); { BTParallel parallel = new BTParallel(BTParallel.ParallelFunction.Or); { parallel.AddChild(findToTargetDestination); // 先找到走到攻击目标的目的地 BTSequence rotateAndMove = new BTSequence(); { rotateAndMove.AddChild(monsterMoveRotate); rotateAndMove.AddChild(move); } parallel.AddChild(rotateAndMove); // 怪物朝着目的地移动 } attack.AddChild(parallel); attack.AddChild(attackRotate); // 怪物朝向玩家 attack.AddChild(monsterAttack); // 进行攻击 } root.AddChild(attack); // 随机巡逻 BTSequence randomMove = new BTSequence(playerNotInRange); { randomMove.AddChild(monsterWait); // 怪物静止几秒 BTParallel parallel = new BTParallel(BTParallel.ParallelFunction.And); { parallel.AddChild(randomMoveDistance); // 随机找一个移动地点 BTSequence rotateAndMove = new BTSequence(); { rotateAndMove.AddChild(monsterMoveRotate); rotateAndMove.AddChild(move); } parallel.AddChild(rotateAndMove); // 怪物朝着目的地移动 } randomMove.AddChild(parallel); } root.AddChild(randomMove); }
private void Awake() { this._localMove = GetComponent <MonsterMove>(); }