public void Create() { if (mIsInit == false) { PFMissile = Resources.Load <CMissile>("Prefabs/PFMissile"); PFPlayer = Resources.Load <CPlayer>("Prefabs/PFPlayer"); mIsInit = true; } }
protected CMissile CreateMissile(Vector3 dir, Color color) { CMissile tMissile = Instantiate <CMissile>(CGameDataMgr.GetInst().PFMissile, transform.position, Quaternion.identity); tMissile.Direction = dir.normalized; tMissile.SetTargetTag("tagPlayer"); tMissile.SetColor(color); tMissile.SetATK(mATK); return(tMissile); }
private void CreateLaserBeamParts( CBoardElement[][] oBoardElements, LinkedList <ICTank> oTanks) { int posXOfLaserBeamPart = mController.CanonPositionX(); int posYOfLaserBeamPart = mController.CanonPositionY(); bool createNextLaserBeamPart = true; do { switch (mController.GetDirection()) { case EDirection.DOWN: posYOfLaserBeamPart++; break; case EDirection.LEFT: posXOfLaserBeamPart--; break; case EDirection.RIGHT: posXOfLaserBeamPart++; break; case EDirection.UP: posYOfLaserBeamPart--; break; } CMissile cMissile = new CMissile( mController, posXOfLaserBeamPart, posYOfLaserBeamPart, mController.GetDirection()); if (cMissile.Collision( oBoardElements, oTanks, false)) { createNextLaserBeamPart = false; } else { mController.LaserBeamParts.AddLast(cMissile); } } while (createNextLaserBeamPart); mPosOfLaserBeamCollision.SetPosX(posXOfLaserBeamPart); mPosOfLaserBeamCollision.SetPosY(posYOfLaserBeamPart); }
private void DoMove() { float tHorizontal = Input.GetAxis("Horizontal"); float tVertical = Input.GetAxis("Vertical"); mAnimator.SetInteger("aniMoveHorizontal", Mathf.CeilToInt(tHorizontal)); if (mAnimator.GetInteger("aniMoveHorizontal") == -1) { mSpriteBody.flipX = true; } else { mSpriteBody.flipX = false; } mAnimator.SetInteger("aniMoveVertical", Mathf.CeilToInt(tVertical)); Vector2 pos = transform.localPosition; pos.x = Mathf.Clamp(pos.x + (tHorizontal * mMoveSpeed * Time.deltaTime), -mMapWidth, mMapWidth); pos.y = Mathf.Clamp(pos.y + (tVertical * mMoveSpeed * Time.deltaTime), -mMapHeight, mMapHeight - mCollider.size.y / 2); transform.localPosition = pos; if (mFireTime >= mFireDelay) { Vector2 tFireDirection = Vector2.zero; tFireDirection.x = Input.GetAxisRaw("FireHorizontal"); tFireDirection.y = Input.GetAxisRaw("FireVertical"); if (tFireDirection.x != 0) { CMissile tMissile = Instantiate <CMissile>(CGameDataMgr.GetInst().PFMissile, mFireTransform.position, Quaternion.identity); tMissile.Direction = new Vector2(tFireDirection.x, 0); tMissile.SetTargetTag("tagEnemy"); tMissile.SetATK(mATK); mFireTime = 0; } else if (tFireDirection.y != 0) { CMissile tMissile = Instantiate <CMissile>(CGameDataMgr.GetInst().PFMissile, mFireTransform.position, Quaternion.identity); tMissile.Direction = new Vector2(0, tFireDirection.y); tMissile.SetTargetTag("tagEnemy"); tMissile.SetATK(mATK); mFireTime = 0; } } else { mFireTime += Time.deltaTime; } }
/// <summary> /// Creates entity and assigns ID. /// </summary> public static CEntity Create(EType Type, CWorld World, int ID = 0) { CEntity entity = null; switch (Type) { case EType.UNIT: entity = new CUnit(); break; case EType.ITEM_START: entity = new CItemStart(); break; case EType.ITEM_DECO: entity = new CItemDeco(); break; case EType.ITEM_DESK: entity = new CItemDesk(); break; case EType.ITEM_SAFE: entity = new CItemSafe(); break; case EType.ITEM_REST: entity = new CItemRest(); break; case EType.ITEM_FOOD: entity = new CItemFood(); break; case EType.ITEM_DOOR: entity = new CItemDoor(); break; case EType.RESUME: entity = new CResume(); break; case EType.CONTRACT: entity = new CContract(); break; case EType.PICKUP: entity = new CPickup(); break; case EType.MISSILE: entity = new CMissile(); break; case EType.VOLUME: entity = new CVolume(); break; case EType.DECAL: entity = new CDecal(); break; } if (entity != null) { _InitNewEntity(entity, World, ID); } else { Debug.LogError("Entity Factory couldn't create a " + (int)Type + " is"); } return(entity); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.D)) { CMissile sideWinder = ScriptableObject.CreateInstance <CSideWinder>(); sideWinder.ApplySeek(); CMissile tomahawk = ScriptableObject.CreateInstance <CTomahawk>(); tomahawk.ApplySeek(); CMissile torpedo = ScriptableObject.CreateInstance <CTorpedo>(); torpedo.ApplySeek(); CMissile sideWinderWithSonar = ScriptableObject.CreateInstance <CSideWinder>(); ISeekBehaviour sonar = new CSeekWithSonar(); sideWinderWithSonar.setSeekBehaviour(sonar); sideWinderWithSonar.ApplySeek(); } }
public void CopyState(CMissile Missile) { mPosition = Missile.mRealPosition; mVelocity = Missile.mVelocity; mDead = Missile.mDead; }
public void CopyInitialState(CMissile Missile) { mID = Missile.mID; mOwnerID = Missile.mOwner; }