// Use this for initialization void Start() { anim = player.GetComponent <Animator>(); splineMoveScript = player.GetComponent <splineMove>(); speedAdjust = splineMoveScript.speed; colSound = player.GetComponent <AudioSource>(); }
public void InitItem() { splineMove = GetComponent <splineMove>(); if (null == splineMove) { splineMove = gameObject.AddComponent <splineMove>(); } boxcollider = GetComponent <BoxCollider2D>(); foodImg = GetComponent <Image>(); splineMove.pathContainer = GameCtrl._Ins.mapCurve; splineMove.speed = GameCtrl._Ins.GetCurrLevelData().Movespeed; splineMove.pathMode = DG.Tweening.PathMode.TopDown2D; splineMove.loopType = splineMove.LoopType.loop; //Debug.Log($"{transform.name} = {transform.position},vector[0]:{splineMove.pathContainer.GetPathPoints()[0]}"); //transform.position = splineMove.pathContainer.GetPathPoints()[0]; //Debug.Log($"{transform.name} = {transform.position},vector[0]:{splineMove.pathContainer.GetPathPoints()[0]}"); splineMove.StartMove(); // 事件必须在 startMove() 调用了在添加 //Debug.Log($"曲线事件长度 = {splineMove.events.Count}"); UnityEvent myEvent = splineMove.events[splineMove.events.Count - 1]; myEvent.RemoveAllListeners(); myEvent.AddListener(() => { //Debug.Log($"到达曲线终点,pointIndex = {splineMove.events.Count - 1}"); ResetItem(); GameCtrl._Ins.EC.OnFoodArriveEndPoint?.Invoke(this); }); }
void Start() { abilities = GetComponent <EnemySpells>().ability; safeAbility = GetComponent <EnemySpells>().safeAbility; targets = FindObjectsOfType <Fighter>(); mover = GetComponent <Mover>(); onRailsMover = GetComponent <OnRailsMover>(); cooldown = GetComponent <CoolDown>(); channel = GetComponent <Channel>(); attackIndicator = GetComponent <AttackIndicator>(); attackReceiver = GetComponent <AttackReceiver>(); attackExecutor = GetComponent <AttackExecutor>(); enemyTarget = GetComponent <EnemyTarget>(); spline = GetComponent <splineMove>(); stateMachine = GetComponent <StateMachine>(); animationHandler = GetComponent <AnimationHandler>(); allEnemies = FindObjectsOfType <EnemyTarget>(); allActors = FindObjectsOfType <Fighter>(); allPushables = FindObjectsOfType <Pushable>(); combatController = FindObjectOfType <CombatController>(); cooldown.isOnCD = true; channel.isChanneling = false; channel.channel = 0f; //print("allPushables start count: " + allPushables.Length); //perform attack once will be used to check if the current attack is in progress }
void Awake() { // referencing our character animatorManager = GetComponent <Animator>(); agent = GetComponent <splineMove>(); canInteract = false; }
public void Reset() { ////transform.localPosition = _storagePosition; //Vector3 testWayPoint = mWayPointList.GetVector3AtIndex (1); //transform.localPosition = testWayPoint; ////transform.localPosition = _startPosition; //mCurrentWayPoint = 0; //mOnEndPoint = false; spline = GetComponent <splineMove> (); float speed = spline.speed; Debug.Log("speed = " + speed); spline.StartMove(); //spline.Stop (); //_State = eState.GetWayPoint; }
void Execute() { var go = Fsm.GetOwnerDefaultTarget(walkerObject); if (go == null) { return; } List <UnityEvent> events = null; splineMove spline = go.GetComponentInChildren <splineMove>(); if (spline) { events = spline.events; } else { navMove nav = go.GetComponentInChildren <navMove>(); if (nav) { events = nav.events; } } UnityEvent myEvent = events[wpIndex.Value]; myEvent.AddListener(delegate { fsmReceiver.SendEvent(fsmEvent.Value); }); }
void Start() { mover = GetComponent <Mover>(); enemyTarget = GetComponent <EnemyTarget>(); combatController = FindObjectOfType <CombatController>(); spline = GetComponent <splineMove>(); savedWing = GetComponent <EnemyTarget>().wing; }
void Start() { move = GetComponent <splineMove>(); move.StartMove(); move.Pause(); progress = 0f; _speed = speed; }
//get references at start //initialize movement but don't start it yet void Start() { animator = GetComponent <Animator>(); move = GetComponent <splineMove>(); move.StartMove(); //move.Pause(); progress = 0f; }
public void Init(CGame_Fishing game, splineMove move, uint index, byte typeId) { AssetBundle ab = game.FishingAssetBundle; m_Animator = GetComponent <Animator>(); m_Animator.speed = 0f; m_SplineMove = move; m_nOnlyId = index; m_nTypeId = typeId; m_Renderers = gameObject.GetComponentsInChildren <Renderer>(); foreach (Renderer child in m_Renderers) { child.enabled = false; } if (m_SplineMove != null) { if (m_SplineMove.loopType != splineMove.LoopType.loop) { m_SplineMove.tween.OnComplete(OnComplete); } m_SplineMove.tween.OnPlay(OnPlay); } else { OnPlay(); } m_LockSitList.Clear(); m_LockPointTfm = transform.parent.Find("Point_LockTarget"); FishingFishData fd = Fishing_Data.GetInstance().m_FishData[m_nTypeId]; if (fd.m_nHitAudio != 0) { m_HitSound = gameObject.AddComponent <AudioSource>(); m_HitSound.clip = ab.LoadAsset <AudioClip>(CustomAudioDataManager.GetInstance().GetSoundName(fd.m_nHitAudio)); } if (fd.m_nDeadAudio != 0) { m_DeadSound = gameObject.AddComponent <AudioSource>(); m_DeadSound.clip = ab.LoadAsset <AudioClip>(CustomAudioDataManager.GetInstance().GetSoundName(fd.m_nDeadAudio)); } if (fd.m_szTalk.Length > 0) { m_TalkObj = (GameObject)ab.LoadAsset("talk_Image_BG"); m_TalkObj = (GameObject)Instantiate(m_TalkObj); m_TalkObj.GetComponentInChildren <Text>().text = fd.m_szTalk; m_TalkObj.transform.SetParent(game.MainUITfm.Find("point_talk"), false); Invoke("ShowTalk", fd.m_nTalkInterval); Invoke("HideTalk", fd.m_nTalkInterval + fd.m_nTalkShowTime); UpdateTalk(); m_TalkObj.SetActive(false); } }
//getting component references void Start() { animator = GetComponentInChildren <Animator>(); sMove = GetComponent <splineMove>(); if (!sMove) { nAgent = GetComponent <NavMeshAgent>(); } }
public void PerformAttackPath(splineMove pathMover) { //GameEvents.current.AnimationStart(); pathMover.StartMove(); spline.currentPoint = 0; doCheckFinalCellEnemyAttack = true; isMoving = true; combatController.ListOfcells[GetComponent <Mover>().GetGridPos()].isOccupied = false; GetComponent <AnimationHandler>().Run(); savedWing = GetComponent <EnemyTarget>().wing; }
Fishing_Fish[] CreatFish(byte fishTypeId, FishingPathData pd, Transform parent, PathManager pm, uint fishId, int count, float passTime, byte group, byte index) { if (!Fishing_Data.GetInstance().m_FishData.ContainsKey(fishTypeId)) { DebugLog.LogError("fish:" + fishTypeId + " data is error!!"); return(null); } FishingFishData fd = Fishing_Data.GetInstance().m_FishData[fishTypeId]; GameObject prefab = (GameObject)m_GameBase.FishingAssetBundle.LoadAsset(fd.m_szFish); int arrayCount = pd.m_Offsets.Count > 0 ? pd.m_Offsets.Count : 1; Debug.Assert(count != 0 && count <= arrayCount, "create fish count wrong!!"); Fishing_Fish[] fishs = new Fishing_Fish[count]; for (uint j = 0; j < count; j++) { GameObject go = (GameObject)GameMain.instantiate(prefab); go.transform.SetParent(parent, false); splineMove sm = go.AddComponent <splineMove>(); sm.local = true; sm.lookAhead = 0.01f; sm.forwardDir = Vector3.right; sm.pathMode = PathMode.Ignore; sm.offset = index < pd.m_Offsets.Count ? pd.m_Offsets[index] : Vector3.zero; sm.waypointRotation = (fd.m_nRotType == 1) ? splineMove.RotationType.all : splineMove.RotationType.none; if (m_GameBase.IsMirror()) { sm.eulerAngles = (fd.m_nRotType == 1) ? new Vector3(180f, 0f, 0f) : new Vector3(0f, 0f, 180f); } else { sm.eulerAngles = Vector3.zero; } sm.speed = fd.m_GroupSpeed[group]; sm.loopType = pd.m_bLoop ? splineMove.LoopType.loop : splineMove.LoopType.none; sm.SetPath(pm); sm.GoTo(GetPathPassTime(passTime, sm, pd)); if (FishPause) { sm.Pause(); } Fishing_Fish fish = go.transform.Find("skin").gameObject.AddComponent <Fishing_Fish>(); fish.Init(m_GameBase, sm, fishId + j, fishTypeId); fish.OnDeath += RemoveFish; fishs[j] = fish; m_FishDict.Add(fish.m_nOnlyId, fish); } return(fishs); }
void Awake() { animLogo = logo.GetComponent <Animator>(); controller = GetComponent <SteamVR_TrackedObject>(); _splineMove = player.GetComponent <splineMove>(); _splineMoveFront = frontCells.GetComponent <splineMove>(); _splineMoveBack = backCells.GetComponent <splineMove>(); _splineMoveSide = sideCells.GetComponent <splineMove>(); //isStart = _splineMove.onStart; t_script = startText.GetComponent <TextMeshPro>(); }
void Execute() { var go = Fsm.GetOwnerDefaultTarget(walkerObject); if (go == null) { return; } List <UnityEvent> events = null; splineMove spline = go.GetComponentInChildren <splineMove>(); if (spline) { events = spline.events; } else { navMove nav = go.GetComponentInChildren <navMove>(); if (nav) { events = nav.events; } } if (events == null || events.Count == 0) { Debug.Log("RemoveEventsAtWaypoint action could not find events on " + go.name); return; } int size = events.Count; if (wpIndex.Value >= size - 1) { wpIndex.Value = size - 1; } else if (wpIndex.Value <= 0) { wpIndex.Value = 0; } if (size >= wpIndex.Value) { UnityEvent myEvent = events[wpIndex.Value]; myEvent.RemoveAllListeners(); } }
//get references void Start() { move = GetComponent <splineMove>(); if (!move) { Debug.LogWarning(gameObject.name + " missing movement script!"); return; } //set speed to an arbitrary small value //otherwise the tween can't be initialized move.speed = 0.01f; //initialize movement but don't start it yet move.StartMove(); move.Pause(); move.speed = 0f; }
static void DrawGizmoStartPoint(splineMove script, GizmoType gizmoType) { if (script.pathContainer == null) { return; } int maxLength = script.pathContainer.GetPathPoints().Length - 1; int index = Mathf.Clamp(script.startPoint, 0, maxLength); if (script.reverse) { index = maxLength - index; } Vector3 position = script.pathContainer.GetPathPoints()[index]; float size = Mathf.Clamp(HandleUtility.GetHandleSize(position) * 0.1f, 0, 0.3f); Gizmos.color = Color.magenta; Gizmos.DrawSphere(position, size); }
void Start() { _splineMove = GetComponent <splineMove>(); _splineMove.onStart = true; _splineMove.moveToPath = true; _splineMove.loopType = splineMove.LoopType.pingPong; _splineMove.pathType = PathType.Linear; _splineMove.speed = speed; if (lockRotation) { _splineMove.lockRotation = AxisConstraint.Y; } _splineMove.events[0] .AddListener(() => _splineMove.Pause(waitTime)); _splineMove.events[_splineMove.events.Count - 1] .AddListener(() => _splineMove.Pause(waitTime)); }
void MoveToEndOfPathManagerSegment() { if (_currentSplineMove) { _currentSplineMove.Stop(); Destroy(_currentSplineMove); } _currentSplineMove = _oilVehicle.AddComponent <splineMove>(); _currentSplineMove.pathContainer = _currentPathManagerEdge.PathManager; _currentSplineMove.pathMode = DG.Tweening.PathMode.TopDown2D; _currentSplineMove.onStart = true; _currentSplineMove.moveToPath = false; _currentSplineMove.loopType = splineMove.LoopType.none; _currentSplineMove.speed = _currentSpeed; _currentSplineMove.easeType = DG.Tweening.Ease.Linear; var startIndex = _currentPathManagerEdge.EntryWaypoint.transform.GetSiblingIndex(); var endIndex = _currentPathManagerEdge.ExitWaypoint.transform.GetSiblingIndex(); if (reversed) { var temp = endIndex; endIndex = startIndex; startIndex = temp; } _currentSplineMove.reverse = startIndex > endIndex; var bezierPathManager = _currentPathManagerEdge.PathManager as BezierPathManager; var defaultPoints = 10; var startIndexMultiplier = (bezierPathManager != null ? Mathf.CeilToInt(bezierPathManager.pathDetail * defaultPoints) : 1); _currentSplineMove.startPoint = startIndex * startIndexMultiplier + (bezierPathManager != null ? 0 : 0); _oilVehicle.transform.position = _currentPathManagerEdge.PathManager.waypoints[startIndex].transform.position; StartCoroutine(WaitForSplineInitialization()); }
//get references at start //initialize movement but don't start it yet void Start() { myMove = gameObject.GetComponent <splineMove>(); myMove.StartMove(); myMove.Pause(); }
void Start() { moveRef = walker.GetComponent <splineMove>(); input = walker.GetComponent <Test_PathInput>(); initSpeed = input.speed; }
private void Awake() { splineMoveScript = player.GetComponent <splineMove>(); }
private void Awake() { script = GetComponent <splineMove>(); particleLauncher = GetComponentInChildren <ParticleSystem>(); }
float GetPathPassTime(float passTime, splineMove sm, FishingPathData pd) { if (pd.m_ChangePoints.Count == 0) { return(passTime); } float value; float speed = sm.speed; float countTime = passTime; List <byte> changeList = new List <byte>(pd.m_ChangePoints.Keys); if (passTime > 0f) { sm.tween.ForceInit(); TweenerCore <Vector3, Path, PathOptions> tweenPath = sm.tween as TweenerCore <Vector3, Path, PathOptions>; float time = 0f; countTime = 0f; float curSpeed = speed; for (byte i = 0; i < sm.pathContainer.GetWaypointCount(); i++) { value = tweenPath.changeValue.wpLengths[i] / curSpeed; time += value; countTime += value; if (passTime <= time) { countTime -= (time - passTime); break; } if (pd.m_ChangePoints.ContainsKey(i)) { changeList.Remove(i); if (i >= sm.events.Count) { DebugLog.LogWarning("Error: fish point count(" + sm.events.Count + ") out path(" + pd.m_szPath + ") change config!!"); break; } value = pd.m_ChangePoints[i]; if (value > 0f) { sm.events[i].AddListener(() => sm.ChangeSpeed(value * speed)); curSpeed = speed * value; } else { time -= value; if (passTime <= time) { sm.events[i].AddListener(() => sm.Pause(time - passTime)); break; } } } } } foreach (byte i in changeList) { if (i >= sm.events.Count) { DebugLog.LogWarning("Error: fish point count(" + sm.events.Count + ") out path(" + pd.m_szPath + ") change config!!"); break; } value = pd.m_ChangePoints[i]; if (value > 0f) { sm.events[i].AddListener(() => sm.ChangeSpeed(value * speed)); } else { sm.events[i].AddListener(() => sm.Pause(-value)); } } return(countTime); }
private void Awake() { splineMoveScript = player.GetComponent <splineMove>(); touchpadMoveScript = leftController.GetComponent <TouchpadMove>(); }