示例#1
0
    void Start()
    {
        limb       = GetComponentInParent <Limb>();
        controller = GetComponentInParent <StickmanController>();
        ig         = GetComponentInParent <IgnoreCollision>();
        var circleColl = gameObject.AddComponent <CircleCollider2D>();

        circleColl.radius = .05f;
        coll = circleColl;
        if (ig)
        {
            ig.IgnoreCollider(coll);
        }

        rb = GetComponent <Rigidbody2D>();

        parent = transform;
        while (parent.parent)
        {
            parent = parent.parent;
        }
        mask          = ~LayerMask.GetMask("Moveable");
        joint         = gameObject.AddComponent <FixedJoint2D>();
        joint.enabled = false;
    }
示例#2
0
 private void Awake()
 {
     stickmanController = transform.parent.GetComponent <StickmanController>();
     if (!stickmanController)
     {
         Destroy(this);
     }
 }
示例#3
0
    public void Update()
    {
        if (target)
        {
            if (!target.IsAlive())
            {
                target = null;
                animator.SetBool("walk", false);
                animator.SetBool("attack", false);
                return;
            }
            var direction = target.transform.position - transform.position;
            if (Mathf.Abs(direction.magnitude) > 5)
            {
                controller.hip.AddForce(controller.moveSpeed * direction * Vector2.right);
                animator.SetBool("walk", true);
                walking = true;
                animator.SetBool("attack", false);
            }
            else if (walking)
            {
                walking = false;
                animator.SetBool("walk", false);
            }
            else
            {
                animator.SetBool("attack", true);
            }
        }

        foreach (var stickman in PlayerStickman.stickman)
        {
            if (stickman.IsAlive())
            {
                target = stickman.getController();
            }
        }
    }
示例#4
0
 public StickmanLaunchState(StickmanController contoller) : base(contoller)
 {
 }
示例#5
0
 public StickmanAi(StickmanController controller)
 {
     this.controller = controller;
     animator        = controller.animator;
 }
示例#6
0
 public PlayerStickman(StickmanController controller)
 {
     stickman.Add(this);
     this.controller = controller;
     animator        = controller.animator;
 }
示例#7
0
 private void Start()
 {
     controller = GetComponent <StickmanController>();
 }
示例#8
0
 // Start is called before the first frame update
 void Start()
 {
     controller = GetComponentInParent <StickmanController>();
 }
 public StickmanSwingState(StickmanController controller) : base(controller)
 {
 }
示例#10
0
 public StickmanRotationState(StickmanController controller) : base(controller)
 {
 }
 public void SetController(StickmanController controller)
 {
     Controller = controller;
 }
 public StickmanState(StickmanController controller)
 {
     Controller = controller;
 }
 public NoneState(StickmanController controller) : base(controller)
 {
 }