public void GrabFlag(IGrabable flag) { if (flag.GetTeam() == teamType) { return; } if ((flag.GetTransform().position - transform.position).magnitude > minFlagRange) { return; } if (flag.Grabbed()) { return; } flag.GetTransform().SetParent(flagHolder); flag.GetTransform().localPosition = Vector3.zero; flag.GetTransform().localRotation = Quaternion.identity; flag.SetGrabbed(true); flag.GetTransform().GetComponent <BoxCollider>().enabled = false; flagTransform = flag.GetTransform(); }
/// <summary> /// A Flag was grabbed or dropped /// </summary> /// <param name="flag"></param> public override void FlagStatusChangedCallback(IGrabable flag) { if (flag.GetTeam() != soldier.GetTeam()) { // Enemy flag if (flag.Grabbed()) { foreach (TeamRoleBase b in sneakerTeam1) { b.CreateRouteToHomeBase(); } foreach (TeamRoleBase b in sneakerTeam2) { b.CreateRouteToHomeBase(); } } else { // Lost sneakerTeam1.EnemyFlagPosition = flag.GetLocation().ToCell(); sneakerTeam2.EnemyFlagPosition = flag.GetLocation().ToCell(); MyRole.CreateRouteToEnemyFlag(); // Everyone } } else { // Own flag foreach (TeamRoleBase b in sniperTeam1) { b.CreateRouteToHomeBase(); } foreach (TeamRoleBase b in sniperTeam2) { b.CreateRouteToHomeBase(); } } }