本文整理汇总了C#中Controller2D类的典型用法代码示例。如果您正苦于以下问题:C# Controller2D类的具体用法?C# Controller2D怎么用?C# Controller2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Controller2D类属于命名空间,在下文中一共展示了Controller2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
//GameObject arm;
void Start()
{
sounds = GetComponents<AudioSource> ();
gruntSound = sounds [0];
controller = GetComponent<Controller2D> ();
animator = GetComponent<Animator> ();
Cursor.SetCursor(cursorTexture, hotSpot, cursorMode);
currentHealth = maxHealth;
Debug.Log("Current Health: " + currentHealth);
timeHit = Time.time;
currentTime = Time.time;
invincibilityTime = 1;
direction = 1;
_posX = transform.position.x;
someScale = transform.localScale.x;
gravity = -(2 * maxJumpHeight) / Mathf.Pow (timeToJumpApex, 2);
maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
minJumpVelocity = Mathf.Sqrt (2 * Mathf.Abs (gravity) * minJumpHeight);
//print ("Gravity: " + gravity + " Jump Velocity: " + maxJumpVelocity);
pivot = transform.FindChild("Pivot").gameObject;
}
示例2: Start
void Start() {
controller = GetComponent<Controller2D>();
SaveLoad.Load();
Checkpoint.CheckpointsList = GameObject.FindGameObjectsWithTag("Checkpoint");
Debug.Log("Player loaded checkpoint: " + SaveLoad.save.checkpoint);
if (SaveLoad.save.checkpoint != "")
{
Checkpoint cp = GameObject.Find(SaveLoad.save.checkpoint).GetComponent<Checkpoint>();
//cp.activated = true;
cp.ActivateCheckpoint();
this.Respawn();
}
animator = GetComponent<Animator>(); //assign the Animator component on the player gameobject to our new reference var.
//set up jump physics
gravity = -(2 * maxJumpHeight) / Mathf.Pow (timeToJumpApex, 2);
maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
minJumpVelocity = Mathf.Sqrt (2 * Mathf.Abs (gravity) * minJumpHeight);
print ("Gravity: " + gravity + " Jump Velocity: " + maxJumpVelocity);
}
示例3: Start
void Start()
{
controller = GetComponent<Controller2D> ();
gravity = -(2 * jumpHeight) / (timeToJumpApex * timeToJumpApex);
jumpVelocity = Mathf.Abs(gravity * timeToJumpApex);
}
示例4: Start
void Start() {
controller = GetComponent<Controller2D> ();
gravity = -(2 * jumpHeight) / Mathf.Pow (timeToJumpApex, 2);
jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
print ("Gravity: " + gravity + " Jump Velocity: " + jumpVelocity);
}
示例5: Start
void Start()
{
base.Start();
controller = GetComponent<Controller2D>();
spriteRenderer = GetComponent<SpriteRenderer>();
enemySpeed = -enemySpeed;
}
示例6: PowerActionEnter
public override void PowerActionEnter(GameObject player, Controller2D controller){
insideExplosionRange = true;
target = player;
controller.powerInvulnerable = true;
if (playerController == null)
playerController = controller;
}
示例7: PowerActionEnter
public override void PowerActionEnter(GameObject player, Controller2D controller){
if( on ){
portalTo.GetComponent<TeleportPortals>().on = false;
player.transform.position = portalTo.transform.position;
}
Debug.Log( "PORTAL" );
}
示例8: PowerActionEnter
public override void PowerActionEnter (GameObject player, Controller2D controller)
{
if (Analytics.Enabled) {
GA.API.Design.NewEvent ("BlackHole Deaths", player.transform.position);
}
controller.Die();
}
示例9: PowerActionEnter
//Note: Only the host can decide who got hit.
public override void PowerActionEnter (GameObject player, Controller2D controller)
{
//cant stick to yourself again. also wait for response rpc before sending another one.
if (controller.hasbomb || sentRPC) {
return;
}
if (stickready) {
//No need to confirm getting stuck if you're the server.
if (Network.isServer)
{
if (Analytics.Enabled)
{
GA.API.Design.NewEvent ("Players Stuck", player.transform.position);
}
networkView.RPC ("AttachToPlayer", RPCMode.Others, Network.player, firststick);
//do this second so that firstick isnt changed until the end.
AttachToPlayer (Network.player, firststick);
} else {
//We call this incase two people get stuck at around the same time, so that bombs dont
//stick to different characters on different clients.
//Those with lower ping at a disadvantage (since their message gets there first)
// but its probably not important for now.
if (Analytics.Enabled) {
GA.API.Design.NewEvent ("Bomb Transfers", player.transform.position);
}
sentRPC = true;
networkView.RPC ("IThinkIGotStuck", RPCMode.Server);
}
}
}
示例10: PowerActionEnter
public override void PowerActionEnter(GameObject player, Controller2D controller)
{
applyDmg = controller.GetComponent<PlayerStatus>();
if (trapDuration > slowDuration)
{
if (!used)
{
used = true;
player.rigidbody2D.drag = 0;
applyDmg.Frozen();
frozenEffect = (GameObject)Instantiate(Resources.Load("FrozenEffect"), player.transform.position, Quaternion.identity);
frozenEffect.GetComponent<FrozenEffect>().player = controller;
frozenplayer = controller;
currentplayer = player;
networkView.RPC("FreezeFollow", RPCMode.Others, Network.player);
if(Analytics.Enabled){
GA.API.Design.NewEvent("Times Frozen", player.transform.position);
}
}
}
else
{
player.rigidbody2D.drag = 100f;
}
}
示例11: Start
void Start()
{
spriteRenderer = GetComponent<SpriteRenderer>();
controller = GetComponent<Controller2D>();
animator = GetComponent<Animator>();
abilityManager = GetComponent<AbilityManager>();
gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2); // This is some physics formula :)
maxJumpVelocity = Mathf.Abs(gravity * timeToJumpApex);
minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
controller.OnEnemyCollision += OnEnemyCollision;
controller.OnCollectableCollision += OnCollectableCollision;
// TODO: Update enemies list on Update method but with Enumerator on every 1-2 seconds
// TODO: We may not need to update the list on every frame but just to find the new closest enemy.
// TODO: The update for the list entries must be done via message when new enemy dies or spawns.
Enemies = GameObject.FindGameObjectsWithTag("Enemy").ToList();
foreach (GameObject enemy in Enemies)
{
Enemy enemyComponent = enemy.GetComponent<Enemy>();
enemyComponent.OnDeath += OnEnemyDeath;
}
// Currently not working. Find a way to fix this or use mouse targeting
//StartCoroutine(FindClosestEnemy());
}
示例12: Start
protected virtual void Start()
{
player = GetComponent<Player>();
input = player.InputPlayer;//GetComponent<InputController>();
controller = GetComponent<Controller2D>();
movementSpecial = GetComponent<OnMovementSpecial>();
}
示例13: Start
void Start()
{
gameControl = GameObject.FindGameObjectWithTag("GameController");
target = GameObject.FindGameObjectWithTag("Player").transform.GetComponent<Controller2D>();
focusArea = new FocusArea (target.collider.bounds, focusAreaSize);
}
示例14: Start
void Start () {
controller = GetComponent<Controller2D> ();
gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
}
示例15: Start
void Start()
{
audioSource = GetComponent<AudioSource> ();
controller = GetComponent<Controller2D> ();
shootTime = shootTimeNormal;
direction = (Random.Range (1, 11) > 5 ? 1 : -1);
}